]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
cmake: use `CMAKE_REQUIRED_LINK_DIRECTORIES`
authorViktor Szakats <commit@vsz.me>
Sat, 12 Oct 2024 22:34:23 +0000 (00:34 +0200)
committerViktor Szakats <commit@vsz.me>
Mon, 16 Dec 2024 17:35:34 +0000 (18:35 +0100)
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

index 7877f4c9037053658bdb9a682a6cc210f1f4121c..9f70486cca66a01c8e4855cd2b58e81d03ed7cdb 100644 (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()