summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2024-04-11 12:35:24 (GMT)
committerKitware Robot <kwrobot@kitware.com>2024-04-11 12:35:34 (GMT)
commit85f501ed59cb3df68bffc713cd3cfc62ad878f55 (patch)
tree504325ec02a5418b010ff724b958d463e020257c
parent17b3051b85de34621939a3b7a30cafee42476c47 (diff)
parent26e79ed299704f8931131e99639e76f4aa0ee023 (diff)
downloadCMake-85f501ed59cb3df68bffc713cd3cfc62ad878f55.zip
CMake-85f501ed59cb3df68bffc713cd3cfc62ad878f55.tar.gz
CMake-85f501ed59cb3df68bffc713cd3cfc62ad878f55.tar.bz2
Merge topic 'compiler-path-normalization' into release-3.29
26e79ed299 Fix regression on reconfigure with unnormalized -DCMAKE_<LANG>_COMPILER= 1d485a8b45 Tests/RunCMake/CompilerChange: Simplify test cases Acked-by: Kitware Robot <kwrobot@kitware.com> Acked-by: buildbot <buildbot@kitware.com> Acked-by: Ashay Rane <ashay.r@gmail.com> Merge-request: !9416
-rw-r--r--Source/cmGlobalGenerator.cxx14
-rw-r--r--Tests/RunCMake/CompilerChange/CompilerPath-stdout.txt2
-rw-r--r--Tests/RunCMake/CompilerChange/CompilerPath.cmake3
-rw-r--r--Tests/RunCMake/CompilerChange/EmptyCompiler-override.cmake3
-rw-r--r--Tests/RunCMake/CompilerChange/EmptyCompiler-stdout.txt3
-rw-r--r--Tests/RunCMake/CompilerChange/FirstCompiler-stdout.txt2
-rw-r--r--Tests/RunCMake/CompilerChange/FirstCompiler.cmake3
-rw-r--r--Tests/RunCMake/CompilerChange/RunCMakeTest.cmake49
-rw-r--r--Tests/RunCMake/CompilerChange/SecondCompiler-stdout.txt4
-rw-r--r--Tests/RunCMake/CompilerChange/SecondCompiler.cmake3
10 files changed, 40 insertions, 46 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/EmptyCompiler-override.cmake b/Tests/RunCMake/CompilerChange/EmptyCompiler-override.cmake
index 28d29e0..c715d4a 100644
--- a/Tests/RunCMake/CompilerChange/EmptyCompiler-override.cmake
+++ b/Tests/RunCMake/CompilerChange/EmptyCompiler-override.cmake
@@ -1,2 +1 @@
-message(STATUS "CMAKE_C_COMPILER is \"${CMAKE_C_COMPILER}\"")
-file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/cc.cmake" "set(CMAKE_C_COMPILER \"${CMAKE_C_COMPILER}\")\n")
+message(STATUS "CMAKE_C_COMPILER is '${CMAKE_C_COMPILER}'")
diff --git a/Tests/RunCMake/CompilerChange/EmptyCompiler-stdout.txt b/Tests/RunCMake/CompilerChange/EmptyCompiler-stdout.txt
new file mode 100644
index 0000000..caf6b07
--- /dev/null
+++ b/Tests/RunCMake/CompilerChange/EmptyCompiler-stdout.txt
@@ -0,0 +1,3 @@
+-- CMAKE_C_COMPILER is '[^']*/Tests/RunCMake/CompilerChange/cc2.sh'
+.*
+-- CMAKE_C_COMPILER is 'CMAKE_C_COMPILER-NOTFOUND'
diff --git a/Tests/RunCMake/CompilerChange/FirstCompiler-stdout.txt b/Tests/RunCMake/CompilerChange/FirstCompiler-stdout.txt
index 17621b7..137b1d0 100644
--- a/Tests/RunCMake/CompilerChange/FirstCompiler-stdout.txt
+++ b/Tests/RunCMake/CompilerChange/FirstCompiler-stdout.txt
@@ -1 +1 @@
--- CMAKE_C_COMPILER is ".*/Tests/RunCMake/CompilerChange/cc1.sh"
+-- CMAKE_C_COMPILER is '[^']*/Tests/RunCMake/CompilerChange/cc1.sh'
diff --git a/Tests/RunCMake/CompilerChange/FirstCompiler.cmake b/Tests/RunCMake/CompilerChange/FirstCompiler.cmake
index c87ec49..df20bdc 100644
--- a/Tests/RunCMake/CompilerChange/FirstCompiler.cmake
+++ b/Tests/RunCMake/CompilerChange/FirstCompiler.cmake
@@ -1,3 +1,2 @@
enable_language(C)
-message(STATUS "CMAKE_C_COMPILER is \"${CMAKE_C_COMPILER}\"")
-file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/cc.cmake" "set(CMAKE_C_COMPILER \"${CMAKE_C_COMPILER}\")\n")
+message(STATUS "CMAKE_C_COMPILER is '${CMAKE_C_COMPILER}'")
diff --git a/Tests/RunCMake/CompilerChange/RunCMakeTest.cmake b/Tests/RunCMake/CompilerChange/RunCMakeTest.cmake
index 5bb2821..4178de9 100644
--- a/Tests/RunCMake/CompilerChange/RunCMakeTest.cmake
+++ b/Tests/RunCMake/CompilerChange/RunCMakeTest.cmake
@@ -25,34 +25,23 @@ set(cc3 CMAKE_C_COMPILER-NOTFOUND)
configure_file(${ccIn} ${cc1} @ONLY)
configure_file(${ccIn} ${cc2} @ONLY)
-# Use a single build tree for remaining tests without cleaning.
-set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/ChangeCompiler-build)
-set(RunCMake_TEST_NO_CLEAN 1)
-file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}")
+block()
+ set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/ChangeCompiler-build)
+ set(ENV{RunCMake_TEST} "FirstCompiler")
+ run_cmake_with_options(FirstCompiler -DCMAKE_C_COMPILER=${cc1})
+ set(RunCMake_TEST_NO_CLEAN 1)
+ set(ENV{RunCMake_TEST} "SecondCompiler")
+ run_cmake_with_options(SecondCompiler -DCMAKE_C_COMPILER=${cc2})
+ set(ENV{RunCMake_TEST} "EmptyCompiler")
+ run_cmake_with_options(EmptyCompiler -DCMAKE_C_COMPILER=)
+endblock()
-# Check build with compiler wrapper 1.
-set(RunCMake_TEST_OPTIONS -DCMAKE_C_COMPILER=${cc1})
-set(ENV{RunCMake_TEST} "FirstCompiler")
-run_cmake(FirstCompiler)
-include(${RunCMake_TEST_BINARY_DIR}/cc.cmake)
-if(NOT "${CMAKE_C_COMPILER}" STREQUAL "${cc1}")
- message(FATAL_ERROR "FirstCompiler built with compiler:\n ${CMAKE_C_COMPILER}\nand not with:\n ${cc1}")
-endif()
-
-# Check rebuild with compiler wrapper 2.
-set(RunCMake_TEST_OPTIONS -DCMAKE_C_COMPILER=${cc2})
-set(ENV{RunCMake_TEST} "SecondCompiler")
-run_cmake(SecondCompiler)
-include(${RunCMake_TEST_BINARY_DIR}/cc.cmake)
-if(NOT "${CMAKE_C_COMPILER}" STREQUAL "${cc2}")
- message(FATAL_ERROR "SecondCompiler built with compiler:\n ${CMAKE_C_COMPILER}\nand not with:\n ${cc2}")
-endif()
-
-# Check failure with an empty compiler string.
-set(RunCMake_TEST_OPTIONS -DCMAKE_C_COMPILER=)
-set(ENV{RunCMake_TEST} "EmptyCompiler")
-run_cmake(EmptyCompiler)
-include(${RunCMake_TEST_BINARY_DIR}/cc.cmake)
-if(NOT "${CMAKE_C_COMPILER}" STREQUAL "${cc3}")
- message(FATAL_ERROR "Empty built with compiler:\n ${CMAKE_C_COMPILER}\nand not with:\n ${cc3}")
-endif()
+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()
diff --git a/Tests/RunCMake/CompilerChange/SecondCompiler-stdout.txt b/Tests/RunCMake/CompilerChange/SecondCompiler-stdout.txt
index 26ca964..7f90526 100644
--- a/Tests/RunCMake/CompilerChange/SecondCompiler-stdout.txt
+++ b/Tests/RunCMake/CompilerChange/SecondCompiler-stdout.txt
@@ -1 +1,3 @@
--- CMAKE_C_COMPILER is ".*/Tests/RunCMake/CompilerChange/cc2.sh"
+-- CMAKE_C_COMPILER is '[^']*/Tests/RunCMake/CompilerChange/cc1.sh'
+.*
+-- CMAKE_C_COMPILER is '[^']*/Tests/RunCMake/CompilerChange/cc2.sh'
diff --git a/Tests/RunCMake/CompilerChange/SecondCompiler.cmake b/Tests/RunCMake/CompilerChange/SecondCompiler.cmake
index c87ec49..df20bdc 100644
--- a/Tests/RunCMake/CompilerChange/SecondCompiler.cmake
+++ b/Tests/RunCMake/CompilerChange/SecondCompiler.cmake
@@ -1,3 +1,2 @@
enable_language(C)
-message(STATUS "CMAKE_C_COMPILER is \"${CMAKE_C_COMPILER}\"")
-file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/cc.cmake" "set(CMAKE_C_COMPILER \"${CMAKE_C_COMPILER}\")\n")
+message(STATUS "CMAKE_C_COMPILER is '${CMAKE_C_COMPILER}'")