summaryrefslogtreecommitdiffstats
path: root/Modules/Compiler
diff options
context:
space:
mode:
authorSemyon Kolton <semyon.kolton@jetbrains.com>2022-02-15 15:17:24 (GMT)
committerBrad King <brad.king@kitware.com>2022-03-08 21:37:08 (GMT)
commit884d9de8b7d7201a4461711335ac10aae743777d (patch)
treeaa19ae6256be7d17ed296dfad89bbece1f9e1770 /Modules/Compiler
parent2ac3db2d42482c70631d8be5badc44e61298afd5 (diff)
downloadCMake-884d9de8b7d7201a4461711335ac10aae743777d.zip
CMake-884d9de8b7d7201a4461711335ac10aae743777d.tar.gz
CMake-884d9de8b7d7201a4461711335ac10aae743777d.tar.bz2
color: Introduce CMAKE_COLOR_DIAGNOSTICS variable
Add a variable to control both makefile color messages and compiler color diagnostics. Fixes: #15502
Diffstat (limited to 'Modules/Compiler')
-rw-r--r--Modules/Compiler/Clang.cmake6
-rw-r--r--Modules/Compiler/GNU.cmake7
2 files changed, 13 insertions, 0 deletions
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()