diff options
-rw-r--r-- | Modules/CMakeDetermineCompilerId.cmake | 11 | ||||
-rw-r--r-- | Tests/RunCMake/CMakeLists.txt | 1 | ||||
-rw-r--r-- | Tests/RunCMake/InitialFlags/C-stdout.txt | 1 | ||||
-rw-r--r-- | Tests/RunCMake/InitialFlags/C.cmake | 3 | ||||
-rw-r--r-- | Tests/RunCMake/InitialFlags/CMakeLists.txt | 3 | ||||
-rw-r--r-- | Tests/RunCMake/InitialFlags/CXX-stdout.txt | 1 | ||||
-rw-r--r-- | Tests/RunCMake/InitialFlags/CXX.cmake | 3 | ||||
-rw-r--r-- | Tests/RunCMake/InitialFlags/RunCMakeTest.cmake | 7 |
8 files changed, 25 insertions, 5 deletions
diff --git a/Modules/CMakeDetermineCompilerId.cmake b/Modules/CMakeDetermineCompilerId.cmake index 1595cfd73c..ad9503c587 100644 --- a/Modules/CMakeDetermineCompilerId.cmake +++ b/Modules/CMakeDetermineCompilerId.cmake @@ -1,9 +1,9 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -macro(__determine_compiler_id_test testflags_in userflags) - separate_arguments(testflags UNIX_COMMAND "${testflags_in}") - CMAKE_DETERMINE_COMPILER_ID_BUILD("${lang}" "${testflags}" "${userflags}" "${src}") +macro(__determine_compiler_id_test testflags_var userflags_var) + separate_arguments(testflags UNIX_COMMAND "${${testflags_var}}") + CMAKE_DETERMINE_COMPILER_ID_BUILD("${lang}" "${testflags}" "${${userflags_var}}" "${src}") CMAKE_DETERMINE_COMPILER_ID_MATCH_VENDOR("${lang}" "${COMPILER_${lang}_PRODUCED_OUTPUT}") if(NOT CMAKE_${lang}_COMPILER_ID) @@ -44,7 +44,8 @@ function(CMAKE_DETERMINE_COMPILER_ID lang flagvar src) endif() foreach(userflags "${CMAKE_${lang}_COMPILER_ID_FLAGS_LIST}" "") - __determine_compiler_id_test("${CMAKE_${lang}_COMPILER_ID_TEST_FLAGS_FIRST}" "${userflags}") + set(testflags "${CMAKE_${lang}_COMPILER_ID_TEST_FLAGS_FIRST}") + __determine_compiler_id_test(testflags userflags) if(CMAKE_${lang}_COMPILER_ID) break() endif() @@ -55,7 +56,7 @@ function(CMAKE_DETERMINE_COMPILER_ID lang flagvar src) # of helper flags. Stop when the compiler is identified. foreach(userflags "${CMAKE_${lang}_COMPILER_ID_FLAGS_LIST}" "") foreach(testflags ${CMAKE_${lang}_COMPILER_ID_TEST_FLAGS_FIRST} "" ${CMAKE_${lang}_COMPILER_ID_TEST_FLAGS}) - __determine_compiler_id_test("${testflags}" "${userflags}") + __determine_compiler_id_test(testflags userflags) if(CMAKE_${lang}_COMPILER_ID) break() endif() diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index f33e4af1a1..78e0b6aee0 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -243,6 +243,7 @@ add_RunCMake_test(FileAPI -DPYTHON_EXECUTABLE=${PYTHON_EXECUTABLE} add_RunCMake_test(FindBoost) add_RunCMake_test(FindLua) add_RunCMake_test(FindOpenGL) +add_RunCMake_test(InitialFlags) if(CMake_TEST_FindOpenSSL) add_RunCMake_test(FindOpenSSL) endif() diff --git a/Tests/RunCMake/InitialFlags/C-stdout.txt b/Tests/RunCMake/InitialFlags/C-stdout.txt new file mode 100644 index 0000000000..9a7341d2f7 --- /dev/null +++ b/Tests/RunCMake/InitialFlags/C-stdout.txt @@ -0,0 +1 @@ +CMAKE_C_FLAGS='[^']*-Denv="a\\b"[^']+-Dvar="b\\c"[^']*' diff --git a/Tests/RunCMake/InitialFlags/C.cmake b/Tests/RunCMake/InitialFlags/C.cmake new file mode 100644 index 0000000000..5afc395597 --- /dev/null +++ b/Tests/RunCMake/InitialFlags/C.cmake @@ -0,0 +1,3 @@ +set(CMAKE_C_FLAGS_INIT [[-Dvar="b\c"]]) +enable_language(C) +message(STATUS "CMAKE_C_FLAGS='${CMAKE_C_FLAGS}'") diff --git a/Tests/RunCMake/InitialFlags/CMakeLists.txt b/Tests/RunCMake/InitialFlags/CMakeLists.txt new file mode 100644 index 0000000000..7cabeb68b2 --- /dev/null +++ b/Tests/RunCMake/InitialFlags/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 3.20) +project(${RunCMake_TEST} NONE) +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/InitialFlags/CXX-stdout.txt b/Tests/RunCMake/InitialFlags/CXX-stdout.txt new file mode 100644 index 0000000000..623b74a124 --- /dev/null +++ b/Tests/RunCMake/InitialFlags/CXX-stdout.txt @@ -0,0 +1 @@ +CMAKE_CXX_FLAGS='[^']*-Denv="a\\b"[^']+-Dvar="b\\c"[^']*' diff --git a/Tests/RunCMake/InitialFlags/CXX.cmake b/Tests/RunCMake/InitialFlags/CXX.cmake new file mode 100644 index 0000000000..1d7a53cb1a --- /dev/null +++ b/Tests/RunCMake/InitialFlags/CXX.cmake @@ -0,0 +1,3 @@ +set(CMAKE_CXX_FLAGS_INIT [[-Dvar="b\c"]]) +enable_language(CXX) +message(STATUS "CMAKE_CXX_FLAGS='${CMAKE_CXX_FLAGS}'") diff --git a/Tests/RunCMake/InitialFlags/RunCMakeTest.cmake b/Tests/RunCMake/InitialFlags/RunCMakeTest.cmake new file mode 100644 index 0000000000..d13019e537 --- /dev/null +++ b/Tests/RunCMake/InitialFlags/RunCMakeTest.cmake @@ -0,0 +1,7 @@ +include(RunCMake) + +set(ENV{CFLAGS} "$ENV{CFLAGS} -Denv=\"a\\b\"") +run_cmake(C) + +set(ENV{CXXFLAGS} "$ENV{CXXFLAGS} -Denv=\"a\\b\"") +run_cmake(CXX) |