mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-06 05:40:54 -06:00
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 commitscb14ae2b87(try_compile: Add SOURCE_FROM_{ARG,VAR}, 2022-09-21) and611d801790(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.
This commit is contained in:
@@ -38,7 +38,7 @@ endif()
|
||||
if(NOT CMAKE_C_COMPILER_WORKS)
|
||||
PrintTestCompilerStatus("C")
|
||||
__TestCompiler_setTryCompileTargetType()
|
||||
file(WRITE ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testCCompiler.c
|
||||
string(CONCAT __TestCompiler_testCCompilerSource
|
||||
"#ifdef __cplusplus\n"
|
||||
"# error \"The CMAKE_C_COMPILER is set to a C++ compiler\"\n"
|
||||
"#endif\n"
|
||||
@@ -54,8 +54,9 @@ if(NOT CMAKE_C_COMPILER_WORKS)
|
||||
unset(CMAKE_C_COMPILER_WORKS)
|
||||
# Puts test result in cache variable.
|
||||
try_compile(CMAKE_C_COMPILER_WORKS
|
||||
SOURCES ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testCCompiler.c
|
||||
SOURCE_FROM_VAR testCCompiler.c __TestCompiler_testCCompilerSource
|
||||
OUTPUT_VARIABLE __CMAKE_C_COMPILER_OUTPUT)
|
||||
unset(__TestCompiler_testCCompilerSource)
|
||||
# Move result from cache to normal variable.
|
||||
set(CMAKE_C_COMPILER_WORKS ${CMAKE_C_COMPILER_WORKS})
|
||||
unset(CMAKE_C_COMPILER_WORKS CACHE)
|
||||
|
||||
Reference in New Issue
Block a user