summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2024-05-07 12:33:56 +0000
committerKitware Robot <kwrobot@kitware.com>2024-05-07 08:34:04 -0400
commit383f21147a6d7a84da6c40e67293d87b19534363 (patch)
tree8d45087fd19530385c0053be74901a8a18f9e545
parentc373eac9df4afeee4da686c6fdbf84ef3edc6083 (diff)
parent6df925b595220a0db1d7c172f15f39f4bee9f75d (diff)
downloadcmake-383f21147a6d7a84da6c40e67293d87b19534363.tar.gz
Merge topic 'cxx-inspect-without-scanning' into release-3.29
6df925b595 cxxmodules: Do not scan sources while testing the compiler Acked-by: Kitware Robot <kwrobot@kitware.com> Reviewed-by: Ben Boeckel <ben.boeckel@kitware.com> Merge-request: !9494
-rw-r--r--Modules/CMakeDetermineCompilerABI.cmake3
-rw-r--r--Modules/CMakeTestCXXCompiler.cmake13
2 files changed, 16 insertions, 0 deletions
diff --git a/Modules/CMakeDetermineCompilerABI.cmake b/Modules/CMakeDetermineCompilerABI.cmake
index 012a87cafc..87218d207f 100644
--- a/Modules/CMakeDetermineCompilerABI.cmake
+++ b/Modules/CMakeDetermineCompilerABI.cmake
@@ -39,6 +39,9 @@ function(CMAKE_DETERMINE_COMPILER_ABI lang src)
endif()
set(CMAKE_${lang}_RUNTIME_LIBRARY "Static")
endif()
+ if(lang STREQUAL "CXX")
+ set(CMAKE_${lang}_SCAN_FOR_MODULES OFF)
+ endif()
if(NOT "x${CMAKE_${lang}_COMPILER_ID}" STREQUAL "xMSVC")
# Avoid adding our own platform standard libraries for compilers
# from which we might detect implicit link libraries.
diff --git a/Modules/CMakeTestCXXCompiler.cmake b/Modules/CMakeTestCXXCompiler.cmake
index e640ff9b30..a9fbb26ca4 100644
--- a/Modules/CMakeTestCXXCompiler.cmake
+++ b/Modules/CMakeTestCXXCompiler.cmake
@@ -37,6 +37,13 @@ endif()
# any makefiles or projects.
if(NOT CMAKE_CXX_COMPILER_WORKS)
PrintTestCompilerStatus("CXX")
+ # FIXME: Use a block() to isolate the variables we set/unset here.
+ if(DEFINED CMAKE_CXX_SCAN_FOR_MODULES)
+ set(__CMAKE_SAVED_CXX_SCAN_FOR_MODULES "${CMAKE_CXX_SCAN_FOR_MODULES}")
+ else()
+ unset(__CMAKE_SAVED_CXX_SCAN_FOR_MODULES)
+ endif()
+ set(CMAKE_CXX_SCAN_FOR_MODULES OFF)
__TestCompiler_setTryCompileTargetType()
string(CONCAT __TestCompiler_testCXXCompilerSource
"#ifndef __cplusplus\n"
@@ -49,6 +56,12 @@ if(NOT CMAKE_CXX_COMPILER_WORKS)
try_compile(CMAKE_CXX_COMPILER_WORKS
SOURCE_FROM_VAR testCXXCompiler.cxx __TestCompiler_testCXXCompilerSource
OUTPUT_VARIABLE __CMAKE_CXX_COMPILER_OUTPUT)
+ if(DEFINED __CMAKE_SAVED_CXX_SCAN_FOR_MODULES)
+ set(CMAKE_CXX_SCAN_FOR_MODULES "${__CMAKE_SAVED_CXX_SCAN_FOR_MODULES}")
+ unset(__CMAKE_SAVED_CXX_SCAN_FOR_MODULES)
+ else()
+ unset(CMAKE_CXX_SCAN_FOR_MODULES)
+ endif()
unset(__TestCompiler_testCXXCompilerSource)
# Move result from cache to normal variable.
set(CMAKE_CXX_COMPILER_WORKS ${CMAKE_CXX_COMPILER_WORKS})