]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
If compiler allows it and if -DDIAG_COLOR_ALWAYS=yes is provided to
authorJ. Eric Ivancich <ivancich@redhat.com>
Fri, 3 Jun 2016 15:44:03 +0000 (11:44 -0400)
committerJ. Eric Ivancich <ivancich@redhat.com>
Tue, 7 Jun 2016 16:21:49 +0000 (12:21 -0400)
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 <ivancich@redhat.com>
src/CMakeLists.txt

index f34b1b6f09f2b729ee8a3755236792b6e316c378..9fcebb915c3477e2e95ddc8b78856aa7ba429a68 100644 (file)
@@ -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()