From: J. Eric Ivancich Date: Fri, 3 Jun 2016 15:44:03 +0000 (-0400) Subject: If compiler allows it and if -DDIAG_COLOR_ALWAYS=yes is provided to X-Git-Tag: v11.0.0~275^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=3b05f492d6940fd1de57200b5bb0ca80a2b6bec5;p=ceph.git If compiler allows it and if -DDIAG_COLOR_ALWAYS=yes is provided to cmake, turn on diagnostic colors always, even when compiler output does not go directly to terminal (e.g., when piped to "less -R"). Signed-off-by: J. Eric Ivancich --- diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index f34b1b6f09f2..9fcebb915c34 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -90,6 +90,20 @@ else() message(FATAL_ERROR "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support.") endif() + +# if compiler allows it and if -DDIAG_COLOR_ALWAYS=yes is provided to +# cmake, turn on diagnostic colors, even when compiler output does not +# go to terminal (e.g., when piped to less) + +CHECK_C_COMPILER_FLAG("-fdiagnostics-color=always" + COMPILER_SUPPORTS_DIAG_COLOR_ALWAYS) + +if(COMPILER_SUPPORTS_DIAG_COLOR_ALWAYS AND DIAG_COLOR_ALWAYS) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fdiagnostics-color=always") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fdiagnostics-color=always") +endif() + + ## detect sse support # create a tmp file with an empty main()