[cmake] Colorize output when using cmake + ninja. (#674)

Due to how ninja runs clang and gcc, it doesn't colorize the output
like make does. This forces color output in this situation.
This commit is contained in:
Bruce Mitchener 2018-01-04 18:37:35 +07:00 committed by Ebrahim Byagowi
parent 5ed26fc5bd
commit 4f80078eb0
1 changed files with 10 additions and 0 deletions

View File

@ -699,6 +699,16 @@ if (NOT SKIP_INSTALL_LIBRARIES AND NOT SKIP_INSTALL_ALL)
endif ()
endif ()
if (UNIX AND CMAKE_GENERATOR STREQUAL "Ninja")
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
set (CMAKE_CXX_FLAGS "-fcolor-diagnostics ${CMAKE_CXX_FLAGS}")
set (CMAKE_C_FLAGS "-fcolor-diagnostics ${CMAKE_C_FLAGS}")
endif ()
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
set (CMAKE_CXX_FLAGS "-fdiagnostics-color ${CMAKE_CXX_FLAGS}")
set (CMAKE_C_FLAGS "-fdiagnostics-color ${CMAKE_C_FLAGS}")
endif ()
endif ()
## Tests
if (UNIX)