mirror of
https://github.com/curl/curl.git
synced 2026-04-14 18:21:40 +03:00
cmake: fix building with CMAKE_FIND_PACKAGE_PREFER_CONFIG=ON
This CMake global custom option tells it to find dependencies as cmake Configs first, and only then look for `Find*` modules. This may result in `find_package()` succeeding, but without actually creating `CURL::*` imported targets the curl build scripts are expecting. For dependencies with curl-specific, local, `Find*` modules, we always want to use them, via the module detection method, and never a Config-based detection. Ensure this by passing the `MODULE` option to `find_package()` and `find_dependency()` to make them use `Find*` modules unconditionally, making them work as expected with the `CMAKE_FIND_PACKAGE_PREFER_CONFIG=ON` option set. curl uses local Find modules for all dependencies except OpenSSL and ZLIB. The latter two keep using either CMake's built-in Find modules or Config method as before this patch. Also: - apply the same change to `curl-config.cmake`. To fix consuming curl with this option set. Authored-by: Valerie Snyder Ref: #20764 Follow-up to16f073ef49#16973 - GHA/distcheck: add a job testing both building and consuming curl with this option set. (takes 15 seconds) Use custom NGHTTP2 configuration for an extra twist (not required to trigger this issue.) Follow-up tofcde8d7e37#20773 Reported-by: Valerie Snyder Fixes #20729 Closes #20784
This commit is contained in:
parent
3d708e239b
commit
91e06fde1b
4 changed files with 64 additions and 50 deletions
|
|
@ -401,7 +401,7 @@ set(CURL_LIBS "")
|
|||
|
||||
if(ENABLE_ARES)
|
||||
set(USE_ARES 1)
|
||||
find_package(Cares REQUIRED)
|
||||
find_package(Cares MODULE REQUIRED)
|
||||
list(APPEND CURL_LIBS CURL::cares)
|
||||
endif()
|
||||
|
||||
|
|
@ -848,7 +848,7 @@ if(CURL_USE_OPENSSL)
|
|||
endif()
|
||||
|
||||
if(CURL_USE_MBEDTLS)
|
||||
find_package(MbedTLS REQUIRED)
|
||||
find_package(MbedTLS MODULE REQUIRED)
|
||||
if(MBEDTLS_VERSION VERSION_LESS 3.2.0)
|
||||
message(FATAL_ERROR "mbedTLS v3.2.0 or newer is required.")
|
||||
endif()
|
||||
|
|
@ -873,7 +873,7 @@ if(CURL_USE_MBEDTLS)
|
|||
endif()
|
||||
|
||||
if(CURL_USE_WOLFSSL)
|
||||
find_package(WolfSSL REQUIRED)
|
||||
find_package(WolfSSL MODULE REQUIRED)
|
||||
set(_ssl_enabled ON)
|
||||
set(USE_WOLFSSL ON)
|
||||
list(APPEND CURL_LIBS CURL::wolfssl)
|
||||
|
|
@ -891,9 +891,9 @@ if(CURL_USE_WOLFSSL)
|
|||
endif()
|
||||
|
||||
if(CURL_USE_GNUTLS)
|
||||
find_package(GnuTLS REQUIRED)
|
||||
find_package(GnuTLS MODULE REQUIRED)
|
||||
list(APPEND CURL_LIBS CURL::gnutls)
|
||||
find_package(Nettle REQUIRED)
|
||||
find_package(Nettle MODULE REQUIRED)
|
||||
list(APPEND CURL_LIBS CURL::nettle)
|
||||
set(_ssl_enabled ON)
|
||||
set(USE_GNUTLS ON)
|
||||
|
|
@ -914,7 +914,7 @@ if(CURL_USE_GNUTLS)
|
|||
endif()
|
||||
|
||||
if(CURL_USE_RUSTLS)
|
||||
find_package(Rustls REQUIRED)
|
||||
find_package(Rustls MODULE REQUIRED)
|
||||
set(_ssl_enabled ON)
|
||||
set(USE_RUSTLS ON)
|
||||
list(APPEND CURL_LIBS CURL::rustls)
|
||||
|
|
@ -1088,7 +1088,7 @@ endif()
|
|||
|
||||
option(USE_NGHTTP2 "Use nghttp2 library" ON)
|
||||
if(USE_NGHTTP2)
|
||||
find_package(NGHTTP2)
|
||||
find_package(NGHTTP2 MODULE)
|
||||
if(NGHTTP2_FOUND)
|
||||
list(APPEND CURL_LIBS CURL::nghttp2)
|
||||
else()
|
||||
|
|
@ -1102,33 +1102,33 @@ if(USE_NGTCP2)
|
|||
message(FATAL_ERROR "MultiSSL cannot be enabled with HTTP/3 and vice versa.")
|
||||
elseif(USE_OPENSSL OR USE_WOLFSSL)
|
||||
if(USE_WOLFSSL)
|
||||
find_package(NGTCP2 REQUIRED COMPONENTS "wolfSSL")
|
||||
find_package(NGTCP2 MODULE REQUIRED COMPONENTS "wolfSSL")
|
||||
elseif(HAVE_BORINGSSL OR HAVE_AWSLC)
|
||||
find_package(NGTCP2 REQUIRED COMPONENTS "BoringSSL")
|
||||
find_package(NGTCP2 MODULE REQUIRED COMPONENTS "BoringSSL")
|
||||
elseif(OPENSSL_VERSION VERSION_GREATER_EQUAL 3.5.0)
|
||||
find_package(NGTCP2 REQUIRED COMPONENTS "ossl")
|
||||
find_package(NGTCP2 MODULE REQUIRED COMPONENTS "ossl")
|
||||
if(NGTCP2_VERSION VERSION_LESS 1.12.0)
|
||||
message(FATAL_ERROR "ngtcp2 1.12.0 or upper required for OpenSSL")
|
||||
endif()
|
||||
set(OPENSSL_QUIC_API2 1)
|
||||
elseif(HAVE_LIBRESSL)
|
||||
find_package(NGTCP2 COMPONENTS "LibreSSL")
|
||||
find_package(NGTCP2 MODULE COMPONENTS "LibreSSL")
|
||||
if(NOT NGTCP2_FOUND)
|
||||
find_package(NGTCP2 REQUIRED COMPONENTS "quictls") # for ngtcp2 <1.15.0
|
||||
find_package(NGTCP2 MODULE REQUIRED COMPONENTS "quictls") # for ngtcp2 <1.15.0
|
||||
endif()
|
||||
else()
|
||||
find_package(NGTCP2 REQUIRED COMPONENTS "quictls")
|
||||
find_package(NGTCP2 MODULE REQUIRED COMPONENTS "quictls")
|
||||
set(_openssl "quictls")
|
||||
endif()
|
||||
curl_openssl_check_quic()
|
||||
elseif(USE_GNUTLS)
|
||||
find_package(NGTCP2 REQUIRED "GnuTLS")
|
||||
find_package(NGTCP2 MODULE REQUIRED "GnuTLS")
|
||||
else()
|
||||
message(FATAL_ERROR "ngtcp2 requires a supported TLS-backend")
|
||||
endif()
|
||||
list(APPEND CURL_LIBS CURL::ngtcp2)
|
||||
|
||||
find_package(NGHTTP3 REQUIRED)
|
||||
find_package(NGHTTP3 MODULE REQUIRED)
|
||||
set(USE_NGHTTP3 ON)
|
||||
list(APPEND CURL_LIBS CURL::nghttp3)
|
||||
endif()
|
||||
|
|
@ -1140,7 +1140,7 @@ if(USE_QUICHE)
|
|||
elseif(CURL_WITH_MULTI_SSL)
|
||||
message(FATAL_ERROR "MultiSSL cannot be enabled with HTTP/3 and vice versa.")
|
||||
endif()
|
||||
find_package(Quiche REQUIRED)
|
||||
find_package(Quiche MODULE REQUIRED)
|
||||
if(NOT HAVE_BORINGSSL)
|
||||
message(FATAL_ERROR "quiche requires BoringSSL")
|
||||
endif()
|
||||
|
|
@ -1176,7 +1176,7 @@ if(NOT CURL_DISABLE_LDAP)
|
|||
if(USE_OPENSSL)
|
||||
list(APPEND CMAKE_REQUIRED_LIBRARIES OpenSSL::SSL OpenSSL::Crypto)
|
||||
endif()
|
||||
find_package(LDAP)
|
||||
find_package(LDAP MODULE)
|
||||
if(LDAP_FOUND)
|
||||
set(HAVE_LBER_H 1)
|
||||
set(CURL_LIBS CURL::ldap ${CURL_LIBS})
|
||||
|
|
@ -1244,7 +1244,7 @@ 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(Libidn2 MODULE)
|
||||
if(LIBIDN2_FOUND)
|
||||
set(CURL_LIBS CURL::libidn2 ${CURL_LIBS})
|
||||
set(HAVE_IDN2_H 1)
|
||||
|
|
@ -1257,7 +1257,7 @@ option(CURL_USE_LIBPSL "Use libpsl" ON)
|
|||
mark_as_advanced(CURL_USE_LIBPSL)
|
||||
set(USE_LIBPSL OFF)
|
||||
if(CURL_USE_LIBPSL)
|
||||
find_package(Libpsl REQUIRED)
|
||||
find_package(Libpsl MODULE REQUIRED)
|
||||
list(APPEND CURL_LIBS CURL::libpsl)
|
||||
set(USE_LIBPSL ON)
|
||||
endif()
|
||||
|
|
@ -1267,7 +1267,7 @@ option(CURL_USE_LIBSSH2 "Use libssh2" ON)
|
|||
mark_as_advanced(CURL_USE_LIBSSH2)
|
||||
set(USE_LIBSSH2 OFF)
|
||||
if(CURL_USE_LIBSSH2)
|
||||
find_package(Libssh2)
|
||||
find_package(Libssh2 MODULE)
|
||||
if(LIBSSH2_FOUND)
|
||||
set(CURL_LIBS CURL::libssh2 ${CURL_LIBS}) # keep it before TLS-crypto, compression
|
||||
set(USE_LIBSSH2 ON)
|
||||
|
|
@ -1278,7 +1278,7 @@ endif()
|
|||
option(CURL_USE_LIBSSH "Use libssh" OFF)
|
||||
mark_as_advanced(CURL_USE_LIBSSH)
|
||||
if(NOT USE_LIBSSH2 AND CURL_USE_LIBSSH)
|
||||
find_package(Libssh REQUIRED)
|
||||
find_package(Libssh MODULE REQUIRED)
|
||||
set(CURL_LIBS CURL::libssh ${CURL_LIBS}) # keep it before TLS-crypto, compression
|
||||
set(USE_LIBSSH ON)
|
||||
endif()
|
||||
|
|
@ -1286,7 +1286,7 @@ endif()
|
|||
option(CURL_USE_GSASL "Use libgsasl" OFF)
|
||||
mark_as_advanced(CURL_USE_GSASL)
|
||||
if(CURL_USE_GSASL)
|
||||
find_package(Libgsasl REQUIRED)
|
||||
find_package(Libgsasl MODULE REQUIRED)
|
||||
list(APPEND CURL_LIBS CURL::libgsasl)
|
||||
set(USE_GSASL ON)
|
||||
endif()
|
||||
|
|
@ -1295,7 +1295,7 @@ option(CURL_USE_GSSAPI "Use GSSAPI implementation" OFF)
|
|||
mark_as_advanced(CURL_USE_GSSAPI)
|
||||
|
||||
if(CURL_USE_GSSAPI)
|
||||
find_package(GSS)
|
||||
find_package(GSS MODULE)
|
||||
|
||||
set(HAVE_GSSAPI ${GSS_FOUND})
|
||||
if(GSS_FOUND)
|
||||
|
|
@ -1321,7 +1321,7 @@ if(CURL_USE_LIBBACKTRACE)
|
|||
if(NOT CMAKE_BUILD_TYPE MATCHES "(Debug|RelWithDebInfo)")
|
||||
message(FATAL_ERROR "libbacktrace requires debug information")
|
||||
endif()
|
||||
find_package(Libbacktrace REQUIRED)
|
||||
find_package(Libbacktrace MODULE REQUIRED)
|
||||
list(APPEND CURL_LIBS CURL::libbacktrace)
|
||||
set(USE_BACKTRACE ON)
|
||||
endif()
|
||||
|
|
@ -1332,7 +1332,7 @@ if(CURL_USE_LIBUV)
|
|||
if(NOT ENABLE_DEBUG)
|
||||
message(FATAL_ERROR "Using libuv without debug support enabled is useless")
|
||||
endif()
|
||||
find_package(Libuv REQUIRED)
|
||||
find_package(Libuv MODULE REQUIRED)
|
||||
list(APPEND CURL_LIBS CURL::libuv)
|
||||
set(USE_LIBUV ON)
|
||||
set(HAVE_UV_H ON)
|
||||
|
|
@ -1340,7 +1340,7 @@ endif()
|
|||
|
||||
option(USE_LIBRTMP "Enable librtmp from rtmpdump" OFF)
|
||||
if(USE_LIBRTMP)
|
||||
find_package(Librtmp REQUIRED)
|
||||
find_package(Librtmp MODULE REQUIRED)
|
||||
list(APPEND CURL_LIBS CURL::librtmp)
|
||||
endif()
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue