mirror of
https://github.com/Kitware/CMake.git
synced 2026-05-04 05:10:10 -05: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:
@@ -81,16 +81,15 @@ macro(CHECK_FUNCTION_EXISTS FUNCTION VARIABLE)
|
||||
endif()
|
||||
|
||||
if(CMAKE_C_COMPILER_LOADED)
|
||||
set(_cfe_source ${CMAKE_ROOT}/Modules/CheckFunctionExists.c)
|
||||
set(_cfe_source CheckFunctionExists.c)
|
||||
elseif(CMAKE_CXX_COMPILER_LOADED)
|
||||
set(_cfe_source ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CheckFunctionExists/CheckFunctionExists.cxx)
|
||||
configure_file(${CMAKE_ROOT}/Modules/CheckFunctionExists.c "${_cfe_source}" COPYONLY)
|
||||
set(_cfe_source CheckFunctionExists.cxx)
|
||||
else()
|
||||
message(FATAL_ERROR "CHECK_FUNCTION_EXISTS needs either C or CXX language enabled")
|
||||
endif()
|
||||
|
||||
try_compile(${VARIABLE}
|
||||
SOURCES ${_cfe_source}
|
||||
SOURCE_FROM_FILE "${_cfe_source}" "${CMAKE_ROOT}/Modules/CheckFunctionExists.c"
|
||||
COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS}
|
||||
${CHECK_FUNCTION_EXISTS_ADD_LINK_OPTIONS}
|
||||
${CHECK_FUNCTION_EXISTS_ADD_LIBRARIES}
|
||||
|
||||
Reference in New Issue
Block a user