diff options
author | Brad King <brad.king@kitware.com> | 2024-04-10 16:03:17 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2024-04-10 16:03:17 (GMT) |
commit | 26e79ed299704f8931131e99639e76f4aa0ee023 (patch) | |
tree | cee931edc7047419e7913529f4d910bd46136e4b | |
parent | 1d485a8b453dce973d26531d32c66f2de211a446 (diff) | |
download | CMake-26e79ed299704f8931131e99639e76f4aa0ee023.zip CMake-26e79ed299704f8931131e99639e76f4aa0ee023.tar.gz CMake-26e79ed299704f8931131e99639e76f4aa0ee023.tar.bz2 |
Fix regression on reconfigure with unnormalized -DCMAKE_<LANG>_COMPILER=
Since commit 3f2a5971c0 (Modules: CMAKE_*_COMPILER convert path to cmake
path, 2023-12-02, v3.29.0-rc1~292^2) we normalize the path to the
compiler. Update our logic that checks whether the compiler has changed
to account for path normalization.
Fixes: #25883
Issue: #25456
-rw-r--r-- | Source/cmGlobalGenerator.cxx | 14 | ||||
-rw-r--r-- | Tests/RunCMake/CompilerChange/CompilerPath-stdout.txt | 2 | ||||
-rw-r--r-- | Tests/RunCMake/CompilerChange/CompilerPath.cmake | 3 | ||||
-rw-r--r-- | Tests/RunCMake/CompilerChange/RunCMakeTest.cmake | 10 |
4 files changed, 21 insertions, 8 deletions
diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 185bff9..1606eec 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -28,6 +28,7 @@ #include "cm_codecvt_Encoding.hxx" #include "cmAlgorithms.h" +#include "cmCMakePath.h" #include "cmCPackPropertiesGenerator.h" #include "cmComputeTargetDepends.h" #include "cmCryptoHash.h" @@ -270,17 +271,14 @@ void cmGlobalGenerator::ResolveLanguageCompiler(const std::string& lang, std::string changeVars; if (cname && !optional) { - std::string cnameString; + cmCMakePath cachedPath; if (!cmSystemTools::FileIsFullPath(*cname)) { - cnameString = cmSystemTools::FindProgram(*cname); + cachedPath = cmSystemTools::FindProgram(*cname); } else { - cnameString = *cname; + cachedPath = *cname; } - std::string pathString = path; - // get rid of potentially multiple slashes: - cmSystemTools::ConvertToUnixSlashes(cnameString); - cmSystemTools::ConvertToUnixSlashes(pathString); - if (cnameString != pathString) { + cmCMakePath foundPath = path; + if (foundPath.Normal() != cachedPath.Normal()) { cmValue cvars = this->GetCMakeInstance()->GetState()->GetGlobalProperty( "__CMAKE_DELETE_CACHE_CHANGE_VARS_"); if (cvars) { diff --git a/Tests/RunCMake/CompilerChange/CompilerPath-stdout.txt b/Tests/RunCMake/CompilerChange/CompilerPath-stdout.txt new file mode 100644 index 0000000..bf7e220 --- /dev/null +++ b/Tests/RunCMake/CompilerChange/CompilerPath-stdout.txt @@ -0,0 +1,2 @@ +-- CMAKE_C_COMPILER is '[^']*/Tests/RunCMake/CompilerChange/cc1.sh' +-- CACHE_ENTRY='cached' diff --git a/Tests/RunCMake/CompilerChange/CompilerPath.cmake b/Tests/RunCMake/CompilerChange/CompilerPath.cmake new file mode 100644 index 0000000..26cb63d --- /dev/null +++ b/Tests/RunCMake/CompilerChange/CompilerPath.cmake @@ -0,0 +1,3 @@ +enable_language(C) +message(STATUS "CMAKE_C_COMPILER is '${CMAKE_C_COMPILER}'") +message(STATUS "CACHE_ENTRY='${CACHE_ENTRY}'") diff --git a/Tests/RunCMake/CompilerChange/RunCMakeTest.cmake b/Tests/RunCMake/CompilerChange/RunCMakeTest.cmake index eec9c2a..4178de9 100644 --- a/Tests/RunCMake/CompilerChange/RunCMakeTest.cmake +++ b/Tests/RunCMake/CompilerChange/RunCMakeTest.cmake @@ -35,3 +35,13 @@ block() set(ENV{RunCMake_TEST} "EmptyCompiler") run_cmake_with_options(EmptyCompiler -DCMAKE_C_COMPILER=) endblock() + +block() + set(cc1_dot ${RunCMake_BINARY_DIR}/./cc1.sh) + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/CompilerPath-build) + set(RunCMake_TEST_VARIANT_DESCRIPTION "-step1") + run_cmake_with_options(CompilerPath "-DCMAKE_C_COMPILER=${cc1_dot}" -DCACHE_ENTRY=cached) + set(RunCMake_TEST_NO_CLEAN 1) + set(RunCMake_TEST_VARIANT_DESCRIPTION "-step2") + run_cmake_with_options(CompilerPath "-DCMAKE_C_COMPILER=${cc1_dot}") +endblock() |