summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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 0000000..d3d0aa9
--- /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 0799fdd..fc14262 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 7f64ba3..8e0e225 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 805467a..a72c9e1 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 e54a028..cb105ed 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.")