summaryrefslogtreecommitdiff
path: root/Modules/CheckLibraryExists.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/CheckLibraryExists.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/CheckLibraryExists.cmake')
-rw-r--r--Modules/CheckLibraryExists.cmake7
1 files changed, 3 insertions, 4 deletions
diff --git a/Modules/CheckLibraryExists.cmake b/Modules/CheckLibraryExists.cmake
index e126f70a5c..56424ac273 100644
--- a/Modules/CheckLibraryExists.cmake
+++ b/Modules/CheckLibraryExists.cmake
@@ -61,16 +61,15 @@ macro(CHECK_LIBRARY_EXISTS LIBRARY FUNCTION LOCATION VARIABLE)
endif()
if(CMAKE_C_COMPILER_LOADED)
- set(_cle_source ${CMAKE_ROOT}/Modules/CheckFunctionExists.c)
+ set(_cle_source CheckFunctionExists.c)
elseif(CMAKE_CXX_COMPILER_LOADED)
- set(_cle_source ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CheckLibraryExists/CheckFunctionExists.cxx)
- configure_file(${CMAKE_ROOT}/Modules/CheckFunctionExists.c "${_cle_source}" COPYONLY)
+ set(_cle_source CheckFunctionExists.cxx)
else()
message(FATAL_ERROR "CHECK_FUNCTION_EXISTS needs either C or CXX language enabled")
endif()
try_compile(${VARIABLE}
- SOURCES ${_cle_source}
+ SOURCE_FROM_FILE "${_cle_source}" "${CMAKE_ROOT}/Modules/CheckFunctionExists.c"
COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS}
${CHECK_LIBRARY_EXISTS_LINK_OPTIONS}
LINK_LIBRARIES ${CHECK_LIBRARY_EXISTS_LIBRARIES}