From 3dbd4362fd828bcd6f90ddd3e6493d1a294bab60 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Sun, 13 Oct 2024 00:34:23 +0200 Subject: [PATCH] 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 --- CMake/Macros.cmake | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) 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()