cmake: use CMAKE_REQUIRED_LINK_DIRECTORIES

Use `CMAKE_REQUIRED_LINK_DIRECTORIES` with CMake 3.31.0 and upper,
in local macro `curl_required_libpaths()`.

9e95bd49f2
9e95bd49f2
https://gitlab.kitware.com/cmake/cmake/-/merge_requests/9795
https://cmake.org/cmake/help/v3.31/module/CheckSymbolExists.html

Tested OK with cmake 3.31.0-rc1.

Follow-up to 01a8157997 #15271
Follow-up to 7bab201abe #15193

Closes #15280
This commit is contained in:
Viktor Szakats 2024-10-13 00:34:23 +02:00
parent 05ba353435
commit 3dbd4362fd
No known key found for this signature in database
GPG Key ID: B5ABD165E2AEF201

View File

@ -73,10 +73,14 @@ macro(curl_dependency_option _dependency)
endif()
endmacro()
# Convert the passed paths to libpath linker options and add them to CMAKE_REQUIRED_LINK_OPTIONS.
# Convert the passed paths to libpath linker options and add them to CMAKE_REQUIRED_*.
macro(curl_required_libpaths _libpaths_arg)
set(_libpaths "${_libpaths_arg}")
foreach(_libpath IN LISTS _libpaths)
list(APPEND CMAKE_REQUIRED_LINK_OPTIONS "${CMAKE_LIBRARY_PATH_FLAG}${_libpath}")
endforeach()
if(CMAKE_VERSION VERSION_LESS 3.31)
set(_libpaths "${_libpaths_arg}")
foreach(_libpath IN LISTS _libpaths)
list(APPEND CMAKE_REQUIRED_LINK_OPTIONS "${CMAKE_LIBRARY_PATH_FLAG}${_libpath}")
endforeach()
else()
list(APPEND CMAKE_REQUIRED_LINK_DIRECTORIES "${_libpaths_arg}")
endif()
endmacro()