cmake: use color gcc/clang output when possible

Test for the -fdiagnostics-color=auto compiler option supported by gcc
and probably clang, and turn it on if it's available.

This option colorizes compiler warnings/errors/etc. when output to a
terminal.

Also fix a typo above when adding the -fopenmp flag.
This commit is contained in:
Rafael Kitover 2019-01-30 14:29:06 -08:00
parent e912c359f6
commit c6fa7246de
1 changed files with 7 additions and 1 deletions

View File

@ -438,7 +438,13 @@ if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID STREQUAL Clang)
endif()
endif()
set(MYU_C_FLAGS ${MY_C_FLAGS} -fopenmp)
set(MY_C_FLAGS ${MY_C_FLAGS} -fopenmp)
endif()
check_cxx_compiler_flag(-fdiagnostics-color=auto COMPILER_COLOR_OUTPUT)
if(COMPILER_COLOR_OUTPUT)
add_compile_options(-fdiagnostics-color=auto)
endif()
if(MINGW)