build(cmake): use CMAKE_COLOR_DIAGNOSTICS for colored output

- Set CMAKE_COLOR_DIAGNOSTICS instead of adding -fdiagnostics-color to
  CMAKE_CXX_FLAGS and setting CMAKE_COLOR_MAKEFILE
- CMake adds the correct flag for each compiler
- Keep a CMAKE_COLOR_DIAGNOSTICS value given by the user, except with
  DISABLE_COLOR=ON
- The color flag is no longer part of FairMQ_CXX_FLAGS in the package

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Claude
2026-11-09 23:03:44 +00:00
committed by Dennis Klein
parent 13739445e8
commit 08d371b1d4
2 changed files with 6 additions and 6 deletions

View File

@@ -118,7 +118,7 @@ FairMQ sets the compiler flags of each build type:
| `RelWithDebInfo` | `-O3 -g -DNDEBUG`, the warnings, the sanitizers |
| `Release` | `-O3 -DNDEBUG` |
The warnings are `-Wshadow -Wall -Wextra -Wpedantic`. The sanitizers are the flags of the [sanitizer options](#sanitizers). FairMQ also adds `-fdiagnostics-color=always` to `CMAKE_CXX_FLAGS`, or `-fdiagnostics-color=never` with `DISABLE_COLOR`.
The warnings are `-Wshadow -Wall -Wextra -Wpedantic`. The sanitizers are the flags of the [sanitizer options](#sanitizers). FairMQ sets `CMAKE_COLOR_DIAGNOSTICS` to `ON`, or to `OFF` with `DISABLE_COLOR`. CMake then adds the color flag of the compiler, for example `-fdiagnostics-color=always` for GCC. If you set `CMAKE_COLOR_DIAGNOSTICS`, FairMQ keeps your value, but `DISABLE_COLOR=ON` always sets `OFF`.
FairMQ sets the variables `CMAKE_CXX_FLAGS_<CONFIG>` as normal variables. Thus a value from `-DCMAKE_CXX_FLAGS_RELEASE=…` has no effect. Give additional flags in `CMAKE_CXX_FLAGS`.