This is how we can use the color definitions to generate colored status messages:
- We start out with a familiar preamble:
cmake_minimum_required(VERSION 3.5 FATAL_ERROR)
project(recipe-02 LANGUAGES NONE)
- Then, we append the cmake subdirectory to the list of module paths that CMake will search:
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
- We then include the colors.cmake module and call the macro defined within:
include(colors)
define_colors()
- Finally, we print a couple of messages in different colors:
message(STATUS "This is a normal message")
message(STATUS "${Red}This is a red${ColourReset}")
message(STATUS "${BoldRed}This is a bold red${ColourReset}")
message(STATUS "${Green}This is a green${ColourReset}")
message(STATUS "${BoldMagenta}This is bold${ColourReset}")
- Let us test it out (this output should appear colored on your screen if you use macOS or Linux):
