Introduce `CMAKE_COLOR_DIAGNOSTICS` and `CMAKE_COMPILER_COLOR_DIAGNOSTICS` variables
This merge request tries to solve the issue #15502 (closed). See #15502 (comment 1083527) It introduces 2 new CMake variables:
-
CMAKE_COMPILER_COLOR_DIAGNOSTICS. This variable controls whether CMake should enable colored compiler diagnostics via compiler flags. It has 3 states:ON/OFF/not defined.ONwill force colored diagnostics (-fcolor-diagnostics).OFFwill disable colored diagnostics (-fno-color-diagnostics). If the variable is not defined - then CMake will not pass anything and default behavior will be used. By default, this variable isONforNinjagenerators and not defined for other cases. -
CMAKE_COLOR_DIAGNOSTICS. This variable controls all colored diagnostics in CMake. WhenONit will forceCMAKE_COMPILER_COLOR_DIAGNOSTICSandCMAKE_COLOR_MAKEFILEtoON. WhenOFFit does nothing. By default, it'sOFF.
This MR consists of 2 commits. First introduce CMAKE_COMPILER_COLOR_DIAGNOSTICS and second introduces CMAKE_COLOR_DIAGNOSTICS. These are dependent commits, so I was unable to create separate MRs for each of them. However, I consider them as solving separate issues. Variable CMAKE_COMPILER_COLOR_DIAGNOSTICS solve actual issue at hand - no colored diagnostics for CMake. I consider this to be a more critical issue. While the second variable CMAKE_COLOR_DIAGNOSTICS is more of a quality of life variable needed for easier configuration for users.
Fixes: #15502 (closed)