From fc32f152332e8b93f36e9b2fb28666f78eb84878 Mon Sep 17 00:00:00 2001 From: Cristian Adam Date: Fri, 20 Dec 2024 13:59:10 +0100 Subject: [PATCH] CMakePM: Only set CMAKE_COLOR_DIAGNOSTICS for new projects Amends d7f44cdd2417443b2b6e669029a678bf92a991a4 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 --- src/plugins/cmakeprojectmanager/builddirparameters.cpp | 1 - src/plugins/cmakeprojectmanager/cmakebuildconfiguration.cpp | 3 +++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/plugins/cmakeprojectmanager/builddirparameters.cpp b/src/plugins/cmakeprojectmanager/builddirparameters.cpp index 0785ca8d959..9f1a03bdc1e 100644 --- a/src/plugins/cmakeprojectmanager/builddirparameters.cpp +++ b/src/plugins/cmakeprojectmanager/builddirparameters.cpp @@ -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); diff --git a/src/plugins/cmakeprojectmanager/cmakebuildconfiguration.cpp b/src/plugins/cmakeprojectmanager/cmakebuildconfiguration.cpp index 1c5e78980ab..1bc3794e560 100644 --- a/src/plugins/cmakeprojectmanager/cmakebuildconfiguration.cpp +++ b/src/plugins/cmakeprojectmanager/cmakebuildconfiguration.cpp @@ -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);