summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2022-03-09 17:15:45 (GMT)
committerKitware Robot <kwrobot@kitware.com>2022-03-09 17:15:53 (GMT)
commit51e81d1f7354fc425b3fc210900cab37ca00926f (patch)
treefbd06710a3ba6dc94af59103e834846cf8670229 /Modules
parent4802b27e64db507a36c73cdabd7fd2ef01fda228 (diff)
parent6ab9fbd43bfce25cf9ee71a81145a1e5f9dc4a12 (diff)
downloadCMake-51e81d1f7354fc425b3fc210900cab37ca00926f.zip
CMake-51e81d1f7354fc425b3fc210900cab37ca00926f.tar.gz
CMake-51e81d1f7354fc425b3fc210900cab37ca00926f.tar.bz2
Merge topic 'color-diagnostics'
6ab9fbd43b color: Add tests for CMAKE_COLOR_DIAGNOSTICS 78adb1b952 color: Add CMAKE_COLOR_DIAGNOSTICS environment variable 884d9de8b7 color: Introduce CMAKE_COLOR_DIAGNOSTICS variable Acked-by: Kitware Robot <kwrobot@kitware.com> Acked-by: buildbot <buildbot@kitware.com> Acked-by: Frank Dana <ferdnyc@gmail.com> Merge-request: !6990
Diffstat (limited to 'Modules')
-rw-r--r--Modules/CMakeGenericSystem.cmake11
-rw-r--r--Modules/Compiler/Clang.cmake6
-rw-r--r--Modules/Compiler/GNU.cmake7
3 files changed, 21 insertions, 3 deletions
diff --git a/Modules/CMakeGenericSystem.cmake b/Modules/CMakeGenericSystem.cmake
index 6e75fac..e2925dc 100644
--- a/Modules/CMakeGenericSystem.cmake
+++ b/Modules/CMakeGenericSystem.cmake
@@ -47,11 +47,16 @@ set (CMAKE_SKIP_INSTALL_RPATH "NO" CACHE BOOL
set(CMAKE_VERBOSE_MAKEFILE FALSE CACHE BOOL "If this value is on, makefiles will be generated without the .SILENT directive, and all commands will be echoed to the console during the make. This is useful for debugging only. With Visual Studio IDE projects all commands are done without /nologo.")
+if(DEFINED ENV{CMAKE_COLOR_DIAGNOSTICS} AND NOT DEFINED CACHE{CMAKE_COLOR_DIAGNOSTICS})
+ set(CMAKE_COLOR_DIAGNOSTICS $ENV{CMAKE_COLOR_DIAGNOSTICS} CACHE BOOL "Enable colored diagnostics throughout.")
+endif()
+
if(CMAKE_GENERATOR MATCHES "Make")
- set(CMAKE_COLOR_MAKEFILE ON CACHE BOOL
- "Enable/Disable color output during build."
- )
+ if(NOT DEFINED CMAKE_COLOR_DIAGNOSTICS)
+ set(CMAKE_COLOR_MAKEFILE ON CACHE BOOL "Enable/Disable color output during build.")
+ endif()
mark_as_advanced(CMAKE_COLOR_MAKEFILE)
+
if(DEFINED CMAKE_RULE_MESSAGES)
set_property(GLOBAL PROPERTY RULE_MESSAGES ${CMAKE_RULE_MESSAGES})
endif()
diff --git a/Modules/Compiler/Clang.cmake b/Modules/Compiler/Clang.cmake
index f885eb0..df115d3 100644
--- a/Modules/Compiler/Clang.cmake
+++ b/Modules/Compiler/Clang.cmake
@@ -114,6 +114,12 @@ else()
endif()
set(CMAKE_${lang}_COMPILE_OPTIONS_USE_PCH -Xclang -include-pch -Xclang <PCH_FILE> -Xclang -include -Xclang <PCH_HEADER>)
set(CMAKE_${lang}_COMPILE_OPTIONS_CREATE_PCH -Xclang -emit-pch -Xclang -include -Xclang <PCH_HEADER> -x ${__pch_header_${lang}})
+
+ # '-fcolor-diagnostics' introduced since Clang 2.6
+ if(CMAKE_${lang}_COMPILER_VERSION VERSION_GREATER_EQUAL 2.6)
+ set(CMAKE_${lang}_COMPILE_OPTIONS_COLOR_DIAGNOSTICS "-fcolor-diagnostics")
+ set(CMAKE_${lang}_COMPILE_OPTIONS_COLOR_DIAGNOSTICS_OFF "-fno-color-diagnostics")
+ endif()
endmacro()
endif()
diff --git a/Modules/Compiler/GNU.cmake b/Modules/Compiler/GNU.cmake
index 928e726..2eef532 100644
--- a/Modules/Compiler/GNU.cmake
+++ b/Modules/Compiler/GNU.cmake
@@ -119,4 +119,11 @@ macro(__compiler_gnu lang)
set(CMAKE_${lang}_COMPILE_OPTIONS_USE_PCH -include <PCH_HEADER>)
set(CMAKE_${lang}_COMPILE_OPTIONS_CREATE_PCH -x ${__pch_header_${lang}} -include <PCH_HEADER>)
endif()
+
+ # '-fdiagnostics-color=always' introduced since GCC 4.9
+ # https://gcc.gnu.org/gcc-4.9/changes.html
+ if(CMAKE_${lang}_COMPILER_VERSION VERSION_GREATER_EQUAL 4.9)
+ set(CMAKE_${lang}_COMPILE_OPTIONS_COLOR_DIAGNOSTICS "-fdiagnostics-color=always")
+ set(CMAKE_${lang}_COMPILE_OPTIONS_COLOR_DIAGNOSTICS_OFF "-fno-diagnostics-color")
+ endif()
endmacro()