2022-01-20 01:15:16 +08:00
|
|
|
cmake_policy(PUSH)
|
2021-01-09 03:07:00 +08:00
|
|
|
cmake_policy(SET CMP0012 NEW)
|
2022-01-20 01:15:16 +08:00
|
|
|
cmake_policy(SET CMP0054 NEW)
|
|
|
|
cmake_policy(SET CMP0057 NEW)
|
2021-01-09 03:07:00 +08:00
|
|
|
|
2022-01-20 01:15:16 +08:00
|
|
|
if(NOT CMAKE_VERSION VERSION_LESS 3.14 AND COMPONENTS IN_LIST ARGS)
|
|
|
|
include("${CMAKE_CURRENT_LIST_DIR}/CURLConfigComponents.cmake")
|
|
|
|
endif()
|
2019-09-27 12:31:33 +08:00
|
|
|
|
2022-01-20 01:15:16 +08:00
|
|
|
list(REMOVE_ITEM ARGS "NO_MODULE" "CONFIG" "MODULE")
|
|
|
|
_find_package(${ARGS} CONFIG)
|
2019-09-27 12:31:33 +08:00
|
|
|
|
2022-01-20 01:15:16 +08:00
|
|
|
if(CURL_FOUND)
|
2023-01-21 14:12:40 +08:00
|
|
|
include("${CMAKE_ROOT}/Modules/SelectLibraryConfigurations.cmake")
|
|
|
|
|
2023-09-26 15:09:06 +08:00
|
|
|
set(_curl_target CURL::libcurl_shared)
|
|
|
|
if(TARGET CURL::libcurl_static)
|
|
|
|
set(_curl_target CURL::libcurl_static)
|
|
|
|
endif()
|
|
|
|
get_target_property(_curl_include_dirs ${_curl_target} INTERFACE_INCLUDE_DIRECTORIES)
|
|
|
|
get_target_property(_curl_link_libraries ${_curl_target} INTERFACE_LINK_LIBRARIES)
|
2023-01-21 14:12:40 +08:00
|
|
|
if(NOT _curl_link_libraries)
|
|
|
|
set(_curl_link_libraries "")
|
|
|
|
endif()
|
|
|
|
if(_curl_link_libraries MATCHES "ZLIB::ZLIB")
|
|
|
|
string(REGEX REPLACE "([\$]<[^;]*)?ZLIB::ZLIB([^;]*>)?" "${ZLIB_LIBRARIES}" _curl_link_libraries "${_curl_link_libraries}")
|
|
|
|
endif()
|
|
|
|
if(_curl_link_libraries MATCHES "OpenSSL::")
|
|
|
|
string(REGEX REPLACE "([\$]<[^;]*)?OpenSSL::(SSL|Crypto)([^;]*>)?" "${OPENSSL_LIBRARIES}" _curl_link_libraries "${_curl_link_libraries}")
|
|
|
|
endif()
|
2023-07-08 01:09:39 +08:00
|
|
|
if(_curl_link_libraries MATCHES "Libssh2::libssh2_(shared|static)")
|
2023-01-21 14:12:40 +08:00
|
|
|
# TODO: move find_dependency(Libssh2 CONFIG) into CURL config
|
2023-07-08 01:09:39 +08:00
|
|
|
set(_libssh2_target "${CMAKE_MATCH_0}")
|
2023-01-21 14:12:40 +08:00
|
|
|
find_package(Libssh2 CONFIG QUIET)
|
2023-07-08 01:09:39 +08:00
|
|
|
get_target_property(_libssh2_LIBRARY_DEBUG "${_libssh2_target}" IMPORTED_IMPLIB_DEBUG)
|
|
|
|
get_target_property(_libssh2_LIBRARY_RELEASE "${_libssh2_target}" IMPORTED_IMPLIB_RELEASE)
|
2023-01-21 14:12:40 +08:00
|
|
|
if(NOT IMPORTED_IMPLIB_DEBUG AND NOT IMPORTED_IMPLIB_RELEASE)
|
2023-07-08 01:09:39 +08:00
|
|
|
get_target_property(_libssh2_LIBRARY_DEBUG "${_libssh2_target}" IMPORTED_LOCATION_DEBUG)
|
|
|
|
get_target_property(_libssh2_LIBRARY_RELEASE "${_libssh2_target}" IMPORTED_LOCATION_RELEASE)
|
2023-01-21 14:12:40 +08:00
|
|
|
endif()
|
|
|
|
select_library_configurations(_libssh2)
|
2023-07-08 01:09:39 +08:00
|
|
|
string(REGEX REPLACE "([\$]<[^;]*)?${_libssh2_target}([^;]*>)?" "${_libssh2_LIBRARIES}" _curl_link_libraries "${_curl_link_libraries}")
|
2023-01-21 14:12:40 +08:00
|
|
|
unset(_libssh2_LIBRARIES)
|
|
|
|
unset(_libssh2_LIBRARY_DEBUG)
|
|
|
|
unset(_libssh2_LIBRARY_RELEASE)
|
2023-07-08 01:09:39 +08:00
|
|
|
unset(_libssh2_target)
|
2023-01-21 14:12:40 +08:00
|
|
|
endif()
|
|
|
|
if(_curl_link_libraries MATCHES "::")
|
|
|
|
message(WARNING "CURL_LIBRARIES list at least one target. This will not work for use cases where targets are not resolved.")
|
|
|
|
endif()
|
2019-09-27 12:31:33 +08:00
|
|
|
|
|
|
|
if (CMAKE_SYSTEM_NAME STREQUAL "Windows" OR CMAKE_SYSTEM_NAME STREQUAL "WindowsStore")
|
2023-09-26 15:09:06 +08:00
|
|
|
get_target_property(_curl_location_debug ${_curl_target} IMPORTED_IMPLIB_DEBUG)
|
|
|
|
get_target_property(_curl_location_release ${_curl_target} IMPORTED_IMPLIB_RELEASE)
|
2019-09-27 12:31:33 +08:00
|
|
|
endif()
|
|
|
|
|
|
|
|
if(NOT _curl_location_debug AND NOT _curl_location_release)
|
2023-09-26 15:09:06 +08:00
|
|
|
get_target_property(_curl_location_debug ${_curl_target} IMPORTED_LOCATION_DEBUG)
|
|
|
|
get_target_property(_curl_location_release ${_curl_target} IMPORTED_LOCATION_RELEASE)
|
2019-09-27 12:31:33 +08:00
|
|
|
endif()
|
|
|
|
|
|
|
|
set(CURL_INCLUDE_DIRS "${_curl_include_dirs}")
|
2023-01-21 14:12:40 +08:00
|
|
|
set(CURL_LIBRARY_DEBUG "${_curl_location_debug}" CACHE INTERNAL "vcpkg")
|
|
|
|
set(CURL_LIBRARY_RELEASE "${_curl_location_release}" CACHE INTERNAL "vcpkg")
|
2019-09-27 12:31:33 +08:00
|
|
|
select_library_configurations(CURL)
|
|
|
|
set(CURL_LIBRARIES ${CURL_LIBRARY} ${_curl_link_libraries})
|
|
|
|
set(CURL_VERSION_STRING "${CURL_VERSION}")
|
|
|
|
|
2022-01-20 01:15:16 +08:00
|
|
|
unset(_curl_include_dirs)
|
|
|
|
unset(_curl_link_libraries)
|
|
|
|
unset(_curl_location_debug)
|
|
|
|
unset(_curl_location_release)
|
2023-09-26 15:09:06 +08:00
|
|
|
unset(_curl_target)
|
2019-09-27 12:31:33 +08:00
|
|
|
endif()
|
2022-01-20 01:15:16 +08:00
|
|
|
cmake_policy(POP)
|