diff --git a/CMake/curl-config.cmake.in b/CMake/curl-config.cmake.in index 7dc1f99..e83617e 100644 --- a/CMake/curl-config.cmake.in +++ b/CMake/curl-config.cmake.in @@ -39,6 +39,19 @@ if(@USE_ZLIB@) find_dependency(ZLIB @ZLIB_VERSION_MAJOR@) endif() +if("@USE_ARES@") + find_dependency(c-ares CONFIG) +endif() +if("@USE_LIBSSH2@") + find_dependency(libssh2 CONFIG) +endif() +if("@HAVE_BROTLI@") + find_dependency(unofficial-brotli CONFIG) +endif() +if("@HAVE_ZSTD@") + find_dependency(zstd CONFIG) +endif() + include("${CMAKE_CURRENT_LIST_DIR}/@TARGETS_EXPORT_NAME@.cmake") check_required_components("@PROJECT_NAME@") diff --git a/CMakeLists.txt b/CMakeLists.txt index dbb0bf4..f1a18d1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -234,7 +234,9 @@ set(LIBCURL_PC_REQUIRES_PRIVATE "") if(ENABLE_ARES) set(USE_ARES 1) - find_package(Cares REQUIRED) + find_package(CARES NAMES c-ares REQUIRED) + set(CARES_INCLUDE_DIRS "") + set(CARES_LIBRARIES c-ares::cares) list(APPEND CURL_LIBS ${CARES_LIBRARIES}) list(APPEND LIBCURL_PC_REQUIRES_PRIVATE "libcares") add_definitions("-DCARES_NO_DEPRECATED") # Ignore c-ares deprecation warnings @@ -611,17 +613,11 @@ if(CURL_USE_WOLFSSL) endif() if(CURL_USE_GNUTLS) - if(CURL_USE_PKGCONFIG) - find_package(PkgConfig QUIET) - pkg_check_modules(GNUTLS "gnutls") - if(GNUTLS_FOUND) - set(GNUTLS_LIBRARIES ${GNUTLS_LINK_LIBRARIES}) - endif() - endif() - if(NOT GNUTLS_FOUND) - find_package(GnuTLS REQUIRED) - endif() - find_package(Nettle REQUIRED) + find_package(PkgConfig REQUIRED) + pkg_check_modules(GNUTLS REQUIRED gnutls) + set(GNUTLS_LIBRARIES "${GNUTLS_LINK_LIBRARIES}") + pkg_check_modules(NETTLE REQUIRED nettle) + set(NETTLE_LIBRARIES "${NETTLE_LINK_LIBRARIES}") set(_ssl_enabled ON) set(USE_GNUTLS ON) list(APPEND CURL_LIBS ${GNUTLS_LIBRARIES} ${NETTLE_LIBRARIES}) @@ -685,7 +681,9 @@ endif() option(CURL_BROTLI "Use brotli" OFF) set(HAVE_BROTLI OFF) if(CURL_BROTLI) - find_package(Brotli REQUIRED) + find_package(BROTLI NAMES unofficial-brotli REQUIRED) + set(BROTLI_INCLUDE_DIRS "") + set(BROTLI_LIBRARIES "unofficial::brotli::brotlidec") if(BROTLI_FOUND) set(HAVE_BROTLI ON) list(APPEND CURL_LIBS ${BROTLI_LIBRARIES}) @@ -698,7 +696,9 @@ endif() option(CURL_ZSTD "Use zstd" OFF) set(HAVE_ZSTD OFF) if(CURL_ZSTD) - find_package(Zstd REQUIRED) + find_package(ZSTD NAMES zstd REQUIRED) + set(ZSTD_INCLUDE_DIRS "") + set(ZSTD_LIBRARIES zstd::libzstd) if(ZSTD_FOUND AND NOT ZSTD_VERSION VERSION_LESS 1.0.0) set(HAVE_ZSTD ON) list(APPEND CURL_LIBS ${ZSTD_LIBRARIES}) @@ -1033,7 +1033,9 @@ option(USE_LIBIDN2 "Use libidn2 for IDN support" ON) set(HAVE_IDN2_H OFF) set(HAVE_LIBIDN2 OFF) if(USE_LIBIDN2 AND NOT USE_APPLE_IDN AND NOT USE_WIN32_IDN) - find_package(Libidn2) + find_package(PkgConfig REQUIRED) + pkg_check_modules(LIBIDN2 REQUIRED libidn2) + set(LIBIDN2_LIBRARIES "${LIBIDN2_LINK_LIBRARIES}") if(LIBIDN2_FOUND) set(CURL_LIBS "${LIBIDN2_LIBRARIES};${CURL_LIBS}") list(APPEND CURL_LIBDIRS ${LIBIDN2_LIBRARY_DIRS}) @@ -1054,7 +1056,17 @@ mark_as_advanced(CURL_USE_LIBPSL) set(USE_LIBPSL OFF) if(CURL_USE_LIBPSL) - find_package(Libpsl) # TODO: add REQUIRED to match autotools + find_package(PkgConfig REQUIRED) + pkg_check_modules(LIBPSL REQUIRED libpsl) + # Remove standard win32 libs pulled in transitively from icu + string(REPLACE " " "|" win32_standard_libraries "/(${CMAKE_C_STANDARD_LIBRARIES})[.]lib\$") + foreach(lib IN LISTS LIBPSL_LINK_LIBRARIES) + string(TOLOWER "${lib}" lib_lower) + if(lib_lower MATCHES win32_standard_libraries) + list(REMOVE_ITEM LIBPSL_LINK_LIBRARIES "${lib}") + endif() + endforeach() + set(LIBPSL_LIBRARIES "${LIBPSL_LINK_LIBRARIES}") if(LIBPSL_FOUND) list(APPEND CURL_LIBS ${LIBPSL_LIBRARIES}) list(APPEND LIBCURL_PC_REQUIRES_PRIVATE "libpsl") @@ -1072,7 +1084,9 @@ mark_as_advanced(CURL_USE_LIBSSH2) set(USE_LIBSSH2 OFF) if(CURL_USE_LIBSSH2) - find_package(Libssh2) + find_package(LIBSSH2 NAMES libssh2 REQUIRED) + set(LIBSSH2_LIBRARIES libssh2::libssh2) + get_target_property(LIBSSH2_INCLUDE_DIRS "${LIBSSH2_LIBRARIES}" INTERFACE_INCLUDE_DIRECTORIES) if(LIBSSH2_FOUND) list(APPEND CURL_LIBS ${LIBSSH2_LIBRARIES}) list(APPEND LIBCURL_PC_REQUIRES_PRIVATE "libssh2") @@ -1121,7 +1135,8 @@ endif() option(CURL_USE_GSASL "Use libgsasl" OFF) mark_as_advanced(CURL_USE_GSASL) if(CURL_USE_GSASL) - find_package(Libgsasl REQUIRED) + find_package(PkgConfig REQUIRED) + pkg_check_modules(GSASL REQUIRED libgsasl) if(LIBGSASL_FOUND) list(APPEND CURL_LIBS ${LIBGSASL_LIBRARIES}) list(APPEND CURL_LIBDIRS ${LIBGSASL_LIBRARY_DIRS}) @@ -1139,7 +1154,10 @@ option(CURL_USE_GSSAPI "Use GSSAPI implementation" OFF) mark_as_advanced(CURL_USE_GSSAPI) if(CURL_USE_GSSAPI) - find_package(GSS) + find_package(PkgConfig REQUIRED) + pkg_check_modules(GSS REQUIRED krb5-gssapi) + pkg_get_variable(GSS_FLAVOUR krb5-gssapi vendor) + list(APPEND GSS_LINK_LIBRARIES resolv) # Fixme: move to krb5 pc files set(HAVE_GSSAPI ${GSS_FOUND}) if(GSS_FOUND)