Index: cmake/modules/HandleLLVMOptions.cmake =================================================================== --- cmake/modules/HandleLLVMOptions.cmake +++ cmake/modules/HandleLLVMOptions.cmake @@ -720,11 +720,13 @@ 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