{"id":25406482,"url":"https://github.com/lostincompilation/cmake-message-with-color","last_synced_at":"2026-01-22T12:54:33.505Z","repository":{"id":247498972,"uuid":"825415979","full_name":"LostInCompilation/CMake-Message-with-color","owner":"LostInCompilation","description":"A small CMake helper file to add color formatting functionality to CMake's message()","archived":false,"fork":false,"pushed_at":"2025-04-06T05:39:33.000Z","size":102,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-12T22:56:46.774Z","etag":null,"topics":["cmake","cmake-color","cmake-scripts","color","colorization","formatted-output","formatted-text","message"],"latest_commit_sha":null,"homepage":"","language":"CMake","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"zlib","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/LostInCompilation.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-07-07T17:52:06.000Z","updated_at":"2025-04-06T05:37:36.000Z","dependencies_parsed_at":"2024-07-09T04:23:46.299Z","dependency_job_id":"477152dd-8fc9-481b-8192-abb832f161ae","html_url":"https://github.com/LostInCompilation/CMake-Message-with-color","commit_stats":null,"previous_names":["lostincompilation/cmake-print-colored-text","lostincompilation/cmake-message-with-color"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LostInCompilation%2FCMake-Message-with-color","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LostInCompilation%2FCMake-Message-with-color/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LostInCompilation%2FCMake-Message-with-color/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LostInCompilation%2FCMake-Message-with-color/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/LostInCompilation","download_url":"https://codeload.github.com/LostInCompilation/CMake-Message-with-color/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248643050,"owners_count":21138353,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cmake","cmake-color","cmake-scripts","color","colorization","formatted-output","formatted-text","message"],"created_at":"2025-02-16T05:32:44.255Z","updated_at":"2026-01-22T12:54:33.423Z","avatar_url":"https://github.com/LostInCompilation.png","language":"CMake","funding_links":[],"categories":[],"sub_categories":[],"readme":"# CMake Print Colored Text\n\nA small and easy to use helper to include in your CMake build system to have colored text output, independent of the used Terminal or operating system.\n\n\u003cp align=\"center\"\u003e\n\u003cimg src=\"/img/title_img.png\" alt=\"Title image\" width=\"70%\"/\u003e\n\u003c/p\u003e\n\n## Contents\n- [Description](#description)\n- [Usage](#usage)\n    - [Printing a message with one color](#printing-a-message-with-one-color)\n    - [Printing only parts of the message with color and/or styles](#printing-only-parts-of-the-message-with-color-andor-styles)\n    - [Using multiple colors in one message](#using-multiple-colors-in-one-message)\n- [Supported colors and styles](#supported-colors-and-styles)\n\n*See also: [License (zlib)](LICENSE.md)*\n\n## Description\nThe normal `message(...)` command in CMake sadly doesn't support custom colors or styles for messages. With this helper file you can print messages with colors, have multiple colors in one message, or only have parts of the message printed with color, while the rest of the text in the same line is printed normally.\nThis helper **does not** use ANSI escape codes directly to print the colors and styles. It is fully compatible with every Terminal and every operating system.\n\n## Usage\nJust copy the file `colorFormatting.cmake` next to your ***CMakeLists.txt*** and include it in your ***CMakeLists.txt***:\n```cmake\ninclude(\"colorFormatting.cmake\")\n```\n\n\n### Printing a message with one color\nTo print the whole message with one color and/or style you can use the `messageWithColor(...)` function:\n```cmake\nmessageWithColor(COLOR BLUE \"My message with blue color\")\n```\n#### Only bold\nTo print a message using bold text style and no color change use this argument:\n```cmake\nmessageWithColor(BOLD \"My message in bold text\")\n```\n\n#### Color and bold\nThe bold style can be combined with colors:\n```cmake\nmessageWithColor(BOLD COLOR GREEN \"My message in bold text and green color\")\n```\n\n\n### Printing only parts of the message with color and/or styles\nTo print a part of the message with colors and/or styles, there is another function called `colorFormatText(...)`. It takes the same arguments as `messageWithColor(...)`, but doesn't print anything directly.\nInstead `colorFormatText(...)` sets the variable `COLOR_FORMATTED_TEXT` that you can print yourself. This way you can append unformatted text to formatted text:\n\n```cmake\n# Formatted text is saved in COLOR_FORMATTED_TEXT\ncolorFormatText(COLOR GREEN \"This is green:\")\n\n# Print the formatted text and append unformatted text\nmessage(\"${COLOR_FORMATTED_TEXT} This is without color\")\n```\n\n\u003ch3\u003eResult\u003c/h3\u003e\n\u003cp align=\"center\"\u003e\n\u003cimg src=\"/img/partial_color.png\" alt=\"Partial Color\" width=\"70%\"/\u003e\n\u003c/p\u003e\n\n### Using multiple colors in one message\nTo print a message with multiple colors and/or styles, you can use the `colorFormatTextAppend(...)` function. It takes the same arguments as `colorFormatText(...)`, but doesn't print anything on it's own.\nInstead it *appends* the given string to the `COLOR_FORMATTED_TEXT_COMBINED` variable, that you can print yourself:\n\n```cmake\n# Append multiple strings with different colors and styles\ncolorFormatTextAppend(COLOR RED \"This is \")\ncolorFormatTextAppend(COLOR GREEN \"a multicolor \")\ncolorFormatTextAppend(BOLD COLOR BLUE \"message \")\ncolorFormatTextAppend(COLOR MAGENTA \"test\")\n\n# Print the combined string with multiple colors\nmessage(\"${COLOR_FORMATTED_TEXT_COMBINED}\")\n```\n\n\u003ch3\u003eResult\u003c/h3\u003e\n\u003cp align=\"center\"\u003e\n\u003cimg src=\"/img/multi_color_append.png\" alt=\"Multi Color\" width=\"70%\"/\u003e\n\u003c/p\u003e\n\n\n## Supported colors and styles\n| Color | Style |\n|:-------:|:-------:|\n| \u003ctable\u003e \u003ctr\u003e\u003ctd\u003eNORMAL\u003c/td\u003e\u003c/tr\u003e \u003ctr\u003e\u003ctd\u003eBLACK\u003c/td\u003e\u003c/tr\u003e \u003ctr\u003e\u003ctd\u003eRED\u003c/td\u003e\u003c/tr\u003e \u003ctr\u003e\u003ctd\u003eGREEN\u003c/td\u003e\u003c/tr\u003e \u003ctr\u003e\u003ctd\u003eYELLOW\u003c/td\u003e\u003c/tr\u003e \u003ctr\u003e\u003ctd\u003eBLUE\u003c/td\u003e\u003c/tr\u003e \u003ctr\u003e\u003ctd\u003eMAGENTA\u003c/td\u003e\u003c/tr\u003e \u003ctr\u003e\u003ctd\u003eCYAN\u003c/td\u003e\u003c/tr\u003e \u003ctr\u003e\u003ctd\u003eWHITE\u003c/td\u003e\u003c/tr\u003e \u003c/table\u003e | \u003ctable\u003e \u003ctr\u003e\u003ctd\u003eBOLD\u003c/td\u003e\u003c/tr\u003e \u003c/table\u003e |\n\n**NOTE:** If an invalid color argument is passed to any of the above functions, the text will be printed without any color change. *No error message is printed.*\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flostincompilation%2Fcmake-message-with-color","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flostincompilation%2Fcmake-message-with-color","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flostincompilation%2Fcmake-message-with-color/lists"}