Enable colored diagnostics in ninja builds when building with gcc 4.9+.

GCC has supported -fdiagnostics-color since 4.9.

https://reviews.llvm.org/D47083

llvm-svn: 332793
This commit is contained in:
Nico Weber 2018-05-19 02:36:27 +00:00
parent 434606c8e4
commit 429e06e76b
1 changed files with 6 additions and 4 deletions

View File

@ -720,11 +720,13 @@ add_definitions( -D__STDC_CONSTANT_MACROS )
add_definitions( -D__STDC_FORMAT_MACROS )
add_definitions( -D__STDC_LIMIT_MACROS )
# clang doesn't print colored diagnostics when invoked from Ninja
# clang and gcc don't default-print colored diagnostics when invoked from Ninja.
if (UNIX AND
CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND
CMAKE_GENERATOR STREQUAL "Ninja")
append("-fcolor-diagnostics" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
CMAKE_GENERATOR STREQUAL "Ninja" AND
(CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR
(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND
NOT (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.9))))
append("-fdiagnostics-color" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
endif()
# lld doesn't print colored diagnostics when invoked from Ninja