]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
Change implementation to use a documented CACHE variable, and allow 9487/head
authorJ. Eric Ivancich <ivancich@redhat.com>
Mon, 6 Jun 2016 15:32:01 +0000 (11:32 -0400)
committerJ. Eric Ivancich <ivancich@redhat.com>
Tue, 7 Jun 2016 16:21:49 +0000 (12:21 -0400)
any of the three values supported by GCC to be used. Just as the GCC
default is 'auto', so is the default within the cmake file.

Signed-off-by: J. Eric Ivancich <ivancich@redhat.com>
README.cmake.md
src/CMakeLists.txt

index 0ecba08a384bcf990fa0648a686973f2a8bd411a..347f2ed09d4e2bf69bb49b3e49b58c208f8ea0ea 100644 (file)
@@ -50,15 +50,19 @@ external dependencies:
       ..
 
 If you often pipe `make`to `less` and would like to maintain the
-diagnostic colors for errors and warnings, you can invoke `cmake`
-with:
+diagnostic colors for errors and warnings (and if your compiler
+supports it), you can invoke `cmake` with:
 
-    $ cmake -DDIAG_COLOR_ALWAYS=yes [...]
+    $ cmake -DDIAGNOSTICS_COLOR=always [...]
 
 Then you'll get the diagnostic colors when you execute:
 
     $ make | less -R
 
+Other available values for DIAGNOSTICS_COLOR are 'auto' (default) and
+'never'.
+
+
 **More options will be implemented in the future.**
 
 
index fa21662c7d5eba20ba3041ad17972cda1d20f4f0..3abf8a493729311f4b8ba3920775acdb2ff6cdc2 100644 (file)
@@ -91,22 +91,17 @@ else()
 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)
+## Handle diagnostics color if compiler supports them.
 
 CHECK_C_COMPILER_FLAG("-fdiagnostics-color=always"
-  COMPILER_SUPPORTS_DIAG_COLOR_ALWAYS)
-
-if(DIAG_COLOR_ALWAYS)
-  if(COMPILER_SUPPORTS_DIAG_COLOR_ALWAYS)
-    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fdiagnostics-color=always")
-    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fdiagnostics-color=always")
-    message(STATUS "C and C++ compilers will always show diagnostic colors")
-  else()
-    message(WARNING
-      "Unable to turn on DIAG_COLOR_ALWAYS, because this compiler does not support -fdiagnostics-color=always flag.")
-  endif()
+  COMPILER_SUPPORTS_DIAGNOSTICS_COLOR)
+
+set(DIAGNOSTICS_COLOR "auto"
+  CACHE STRING "Used if the C/C++ compiler supports the -fdiagnostics-color option. May have one of three values -- 'auto' (default), 'always', or 'never'. If set to 'always' and the compiler supports the option, 'make [...] | less -R' will make visible diagnostics colorization of compiler output.")
+
+if(COMPILER_SUPPORTS_DIAGNOSTICS_COLOR)
+  set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fdiagnostics-color=${DIAGNOSTICS_COLOR}")
+  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fdiagnostics-color=${DIAGNOSTICS_COLOR}")
 endif()