From: Viktor Szakats Date: Sat, 12 Oct 2024 22:34:23 +0000 (+0200) Subject: cmake: use `CMAKE_REQUIRED_LINK_DIRECTORIES` X-Git-Tag: curl-8_12_0~341 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3dbd4362fd828bcd6f90ddd3e6493d1a294bab60;p=thirdparty%2Fcurl.git cmake: use `CMAKE_REQUIRED_LINK_DIRECTORIES` Use `CMAKE_REQUIRED_LINK_DIRECTORIES` with CMake 3.31.0 and upper, in local macro `curl_required_libpaths()`. https://github.com/Kitware/CMake/commit/9e95bd49f278cd2a05caf21fd624a41e4bfaba60 https://gitlab.kitware.com/cmake/cmake/-/commit/9e95bd49f278cd2a05caf21fd624a41e4bfaba60 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 01a81579977b3872935d508e306a735f0568d113 #15271 Follow-up to 7bab201abe3915a0167c002f9308950cb8a06e4b #15193 Closes #15280 --- diff --git a/CMake/Macros.cmake b/CMake/Macros.cmake index 7877f4c903..9f70486cca 100644 --- a/CMake/Macros.cmake +++ b/CMake/Macros.cmake @@ -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()