cmake: support LibreSSL native crypto lib with ngtcp 1.15.0+

This commit is contained in:
Viktor Szakats 2025-08-23 10:48:12 +02:00
parent 1e430f806a
commit b6056c2ad5
No known key found for this signature in database
GPG key ID: B5ABD165E2AEF201
3 changed files with 23 additions and 10 deletions

View file

@ -26,11 +26,12 @@
# This module accepts optional COMPONENTS to control the crypto library (these are
# mutually exclusive):
#
# - quictls: Use `libngtcp2_crypto_quictls`. (choose this for LibreSSL)
# - BoringSSL: Use `libngtcp2_crypto_boringssl`. (choose this for AWS-LC)
# - wolfSSL: Use `libngtcp2_crypto_wolfssl`.
# - GnuTLS: Use `libngtcp2_crypto_gnutls`.
# - LibreSSL: Use `libngtcp2_crypto_libressl`. (requires ngtcp2 1.15.0+)
# - ossl: Use `libngtcp2_crypto_ossl`.
# - quictls: Use `libngtcp2_crypto_quictls`.
# - wolfSSL: Use `libngtcp2_crypto_wolfssl`.
#
# Input variables:
#
@ -38,6 +39,7 @@
# - `NGTCP2_LIBRARY`: Path to `ngtcp2` library.
# - `NGTCP2_CRYPTO_BORINGSSL_LIBRARY`: Path to `ngtcp2_crypto_boringssl` library.
# - `NGTCP2_CRYPTO_GNUTLS_LIBRARY`: Path to `ngtcp2_crypto_gnutls` library.
# - `NGTCP2_CRYPTO_LIBRESSL_LIBRARY`: Path to `ngtcp2_crypto_libressl` library.
# - `NGTCP2_CRYPTO_OSSL_LIBRARY`: Path to `ngtcp2_crypto_ossl` library.
# - `NGTCP2_CRYPTO_QUICTLS_LIBRARY`: Path to `ngtcp2_crypto_quictls` library.
# - `NGTCP2_CRYPTO_WOLFSSL_LIBRARY`: Path to `ngtcp2_crypto_wolfssl` library.
@ -55,7 +57,7 @@
if(NGTCP2_FIND_COMPONENTS)
set(_ngtcp2_crypto_backend "")
foreach(_component IN LISTS NGTCP2_FIND_COMPONENTS)
if(_component MATCHES "^(BoringSSL|GnuTLS|ossl|quictls|wolfSSL)")
if(_component MATCHES "^(BoringSSL|GnuTLS|LibreSSL|ossl|quictls|wolfSSL)")
if(_ngtcp2_crypto_backend)
message(FATAL_ERROR "NGTCP2: Only one crypto library can be selected")
endif()
@ -74,11 +76,13 @@ if(_ngtcp2_crypto_backend)
list(APPEND NGTCP2_PC_REQUIRES "lib${_crypto_library_lower}")
endif()
set(_tried_pkgconfig FALSE)
if(CURL_USE_PKGCONFIG AND
NOT DEFINED NGTCP2_INCLUDE_DIR AND
NOT DEFINED NGTCP2_LIBRARY)
find_package(PkgConfig QUIET)
pkg_check_modules(NGTCP2 ${NGTCP2_PC_REQUIRES})
set(_tried_pkgconfig TRUE)
endif()
if(NGTCP2_FOUND)
@ -125,4 +129,9 @@ else()
endif()
mark_as_advanced(NGTCP2_INCLUDE_DIR NGTCP2_LIBRARY NGTCP2_CRYPTO_LIBRARY)
if(NOT NGTCP2_FOUND AND _tried_pkgconfig) # reset variables to allow another round of detection
unset(NGTCP2_INCLUDE_DIR CACHE)
unset(NGTCP2_LIBRARY CACHE)
endif()
endif()

View file

@ -1100,20 +1100,23 @@ 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 "wolfSSL")
find_package(NGTCP2 REQUIRED COMPONENTS "wolfSSL")
elseif(HAVE_BORINGSSL OR HAVE_AWSLC)
find_package(NGTCP2 REQUIRED "BoringSSL")
find_package(NGTCP2 REQUIRED COMPONENTS "BoringSSL")
elseif(OPENSSL_VERSION VERSION_GREATER_EQUAL 3.5.0 AND NOT USE_OPENSSL_QUIC)
find_package(NGTCP2 REQUIRED "ossl")
find_package(NGTCP2 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)
else()
find_package(NGTCP2 REQUIRED "quictls")
if(NOT HAVE_LIBRESSL)
set(_openssl "quictls")
elseif(HAVE_LIBRESSL)
find_package(NGTCP2 COMPONENTS "LibreSSL")
if(NOT NGTCP2_FOUND)
find_package(NGTCP2 REQUIRED COMPONENTS "quictls") # for ngtcp2 1.14.0 or older
endif()
else()
find_package(NGTCP2 REQUIRED COMPONENTS "quictls")
set(_openssl "quictls")
endif()
curl_openssl_check_quic()
elseif(USE_GNUTLS)

View file

@ -436,6 +436,7 @@ Details via CMake
- `NGTCP2_LIBRARY`: Path to `ngtcp2` library.
- `NGTCP2_CRYPTO_BORINGSSL_LIBRARY`: Path to `ngtcp2_crypto_boringssl` library.
- `NGTCP2_CRYPTO_GNUTLS_LIBRARY`: Path to `ngtcp2_crypto_gnutls` library.
- `NGTCP2_CRYPTO_LIBRESSL_LIBRARY`: Path to `ngtcp2_crypto_libressl` library. (requires ngtcp2 1.15.0+)
- `NGTCP2_CRYPTO_OSSL_LIBRARY`: Path to `ngtcp2_crypto_ossl` library.
- `NGTCP2_CRYPTO_QUICTLS_LIBRARY`: Path to `ngtcp2_crypto_quictls` library.
- `NGTCP2_CRYPTO_WOLFSSL_LIBRARY`: Path to `ngtcp2_crypto_wolfssl` library.