CMakePM: Only set CMAKE_COLOR_DIAGNOSTICS for new projects

Amends d7f44cdd24

By having CMAKE_COLOR_DIAGNOSTICS in initial parameters we make sure
that imported projects will not get rebuild.

Having CMAKE_COLOR_DIAGNOSTICS as an environment variable will cause
CMake to set CMAKE_COLOR_DIAGNOSTICS as parameter, and in combination
with CLICOLOR_FORCE would cause on gcc/clang the modification of the
compiler command lines.

See https://cmake.org/cmake/help/latest/variable/
CMAKE_COLOR_DIAGNOSTICS.html for details.

Fixes: QTCREATORBUG-32196
Change-Id: Ia5aa72695ecf7b605bc99caf5b46b2d2f9c6ed20
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
Cristian Adam
2024-12-20 13:59:10 +01:00
parent 6fac43514f
commit fc32f15233
2 changed files with 3 additions and 1 deletions

View File

@@ -112,7 +112,6 @@ BuildDirParameters::BuildDirParameters(CMakeBuildSystem *buildSystem)
environment.set("ICECC", "no");
environment.set("QTC_RUN", "1");
environment.setFallback("CMAKE_COLOR_DIAGNOSTICS", "1");
environment.setFallback("CLICOLOR_FORCE", "1");
cmakeToolId = CMakeKitAspect::cmakeToolId(k);

View File

@@ -1187,6 +1187,9 @@ static CommandLine defaultInitialCMakeCommand(
}
}
// CMake should output colors by default
cmd.addArg("-DCMAKE_COLOR_DIAGNOSTICS:BOOL=ON");
cmd.addArgs(CMakeConfigurationKitAspect::toArgumentsList(k));
cmd.addArgs(CMakeConfigurationKitAspect::additionalConfiguration(k), CommandLine::Raw);