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()