summaryrefslogtreecommitdiff
path: root/Modules/CMakeTestOBJCCompiler.cmake
diff options
context:
space:
mode:
authorMatthew Woehlke <matthew.woehlke@kitware.com>2022-09-26 12:24:03 -0400
committerMatthew Woehlke <matthew.woehlke@kitware.com>2022-09-27 13:29:52 -0400
commitdb76876db5c16d610efd08f6deb0e4c9cd0e5603 (patch)
treeaf62cdbbf0860aee9a3b3a249cbfa578cc01aa33 /Modules/CMakeTestOBJCCompiler.cmake
parent98aef0929f4c5ce7bbf7ce9c2dfc5cad382f5a96 (diff)
downloadcmake-db76876db5c16d610efd08f6deb0e4c9cd0e5603.tar.gz
Modules: Use new SOURCES_FROM_* try_compile (1/2)
Modify some modules that ship with CMake to use the new SOURCES_FROM_* arguments to try_compile / try_run as added by commits cb14ae2b87 (try_compile: Add SOURCE_FROM_{ARG,VAR}, 2022-09-21) and 611d801790 (try_compile: Add SOURCE_FROM_FILE, 2022-09-22). This covers users which previously either used an existing file (but sometimes needed to rename it), or which wrote out their source in entirety. It does NOT cover users that actually need configure_file functionality, as those will be more involved to update and will thus be tackled in part 2.
Diffstat (limited to 'Modules/CMakeTestOBJCCompiler.cmake')
-rw-r--r--Modules/CMakeTestOBJCCompiler.cmake5
1 files changed, 3 insertions, 2 deletions
diff --git a/Modules/CMakeTestOBJCCompiler.cmake b/Modules/CMakeTestOBJCCompiler.cmake
index a8e63198b2..bbc90a76b4 100644
--- a/Modules/CMakeTestOBJCCompiler.cmake
+++ b/Modules/CMakeTestOBJCCompiler.cmake
@@ -38,7 +38,7 @@ endif()
if(NOT CMAKE_OBJC_COMPILER_WORKS)
PrintTestCompilerStatus("OBJC")
__TestCompiler_setTryCompileTargetType()
- file(WRITE ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testOBJCCompiler.m
+ string(CONCAT __TestCompiler_testObjCCompilerSource
"#ifdef __cplusplus\n"
"# error \"The CMAKE_OBJC_COMPILER is set to a C++ compiler\"\n"
"#endif\n"
@@ -51,8 +51,9 @@ if(NOT CMAKE_OBJC_COMPILER_WORKS)
unset(CMAKE_OBJC_COMPILER_WORKS)
# Puts test result in cache variable.
try_compile(CMAKE_OBJC_COMPILER_WORKS
- SOURCES ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testOBJCCompiler.m
+ SOURCE_FROM_VAR testObjCCompiler.m __TestCompiler_testObjCCompilerSource
OUTPUT_VARIABLE __CMAKE_OBJC_COMPILER_OUTPUT)
+ unset(__TestCompiler_testObjCCompilerSource)
# Move result from cache to normal variable.
set(CMAKE_OBJC_COMPILER_WORKS ${CMAKE_OBJC_COMPILER_WORKS})
unset(CMAKE_OBJC_COMPILER_WORKS CACHE)