summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSemyon Kolton <semyon.kolton@jetbrains.com>2022-02-16 12:01:55 +0300
committerBrad King <brad.king@kitware.com>2022-03-08 16:38:13 -0500
commit78adb1b952d92608e8de708084c8cdac69286616 (patch)
tree0a606091197827f9bde8e64d8ad40a045fdcf968
parent884d9de8b7d7201a4461711335ac10aae743777d (diff)
downloadcmake-78adb1b952d92608e8de708084c8cdac69286616.tar.gz
color: Add CMAKE_COLOR_DIAGNOSTICS environment variable
-rw-r--r--Help/envvar/CMAKE_COLOR_DIAGNOSTICS.rst9
-rw-r--r--Help/manual/cmake-env-variables.7.rst1
-rw-r--r--Help/release/dev/color-diagnostics.rst3
-rw-r--r--Help/variable/CMAKE_COLOR_DIAGNOSTICS.rst4
-rw-r--r--Modules/CMakeGenericSystem.cmake4
5 files changed, 20 insertions, 1 deletions
diff --git a/Help/envvar/CMAKE_COLOR_DIAGNOSTICS.rst b/Help/envvar/CMAKE_COLOR_DIAGNOSTICS.rst
new file mode 100644
index 0000000000..d3d0aa94a6
--- /dev/null
+++ b/Help/envvar/CMAKE_COLOR_DIAGNOSTICS.rst
@@ -0,0 +1,9 @@
+CMAKE_COLOR_DIAGNOSTICS
+-----------------------
+
+.. versionadded:: 3.24
+
+.. include:: ENV_VAR.txt
+
+Specifies a default value for the :variable:`CMAKE_COLOR_DIAGNOSTICS` variable
+when there is no explicit value given on the first run.
diff --git a/Help/manual/cmake-env-variables.7.rst b/Help/manual/cmake-env-variables.7.rst
index 0799fddb67..fc142623fe 100644
--- a/Help/manual/cmake-env-variables.7.rst
+++ b/Help/manual/cmake-env-variables.7.rst
@@ -31,6 +31,7 @@ Environment Variables that Control the Build
/envvar/CMAKE_APPLE_SILICON_PROCESSOR
/envvar/CMAKE_BUILD_PARALLEL_LEVEL
/envvar/CMAKE_BUILD_TYPE
+ /envvar/CMAKE_COLOR_DIAGNOSTICS
/envvar/CMAKE_CONFIGURATION_TYPES
/envvar/CMAKE_CONFIG_TYPE
/envvar/CMAKE_EXPORT_COMPILE_COMMANDS
diff --git a/Help/release/dev/color-diagnostics.rst b/Help/release/dev/color-diagnostics.rst
index 7f64ba3687..8e0e2255a5 100644
--- a/Help/release/dev/color-diagnostics.rst
+++ b/Help/release/dev/color-diagnostics.rst
@@ -5,3 +5,6 @@ color-diagnostics
color diagnostics generated by compilers. This variable also controls
color buildsystem messages with :ref:`Makefile Generators`, replacing
:variable:`CMAKE_COLOR_MAKEFILE`.
+
+ The :envvar:`CMAKE_COLOR_DIAGNOSTICS` environment was added to set
+ a default value for :variable:`CMAKE_COLOR_DIAGNOSTICS`.
diff --git a/Help/variable/CMAKE_COLOR_DIAGNOSTICS.rst b/Help/variable/CMAKE_COLOR_DIAGNOSTICS.rst
index 805467a866..a72c9e1999 100644
--- a/Help/variable/CMAKE_COLOR_DIAGNOSTICS.rst
+++ b/Help/variable/CMAKE_COLOR_DIAGNOSTICS.rst
@@ -32,4 +32,6 @@ When ``OFF``:
* GNU/Clang compilers are invoked with a flag disabling color diagnostics
(``-fno-color-diagnostics``).
-``CMAKE_COLOR_DIAGNOSTICS`` is not defined by default.
+If the :envvar:`CMAKE_COLOR_DIAGNOSTICS` environment variable is set, its
+value is used. Otherwise, ``CMAKE_COLOR_DIAGNOSTICS`` is not defined by
+default.
diff --git a/Modules/CMakeGenericSystem.cmake b/Modules/CMakeGenericSystem.cmake
index e54a0287ee..cb105ed1df 100644
--- a/Modules/CMakeGenericSystem.cmake
+++ b/Modules/CMakeGenericSystem.cmake
@@ -47,6 +47,10 @@ 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")
if(NOT DEFINED CMAKE_COLOR_DIAGNOSTICS)
set(CMAKE_COLOR_MAKEFILE ON CACHE BOOL "Enable/Disable color output during build.")