build: use -fdiagnostics-color=always with Ninja (#10419)

"auto" does not work, since Ninja does not appear as a TTY to gcc/clang,
but handles stripping escape codes itself when output is not to a TTY.

Ref: https://github.com/ninja-build/ninja/blob/ca041d88f4d6/src/build.cc#L158-L169
This commit is contained in:
Daniel Hahler 2019-07-04 15:24:33 +02:00 committed by GitHub
parent 05a17e419a
commit 0c639e8777
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -315,7 +315,11 @@ endif()
check_c_compiler_flag(-fdiagnostics-color=auto HAS_DIAG_COLOR_FLAG)
if(HAS_DIAG_COLOR_FLAG)
add_compile_options(-fdiagnostics-color=auto)
if(CMAKE_GENERATOR MATCHES "Ninja")
add_compile_options(-fdiagnostics-color=always)
else()
add_compile_options(-fdiagnostics-color=auto)
endif()
endif()
if(CMAKE_C_COMPILER_ID STREQUAL "GNU")