build: support LibreSSL native crypto lib with ngtcp2 1.15.0+

In ngtcp2 1.15.0 the LibreSSL crypto interface library got its own name:
`libngtcp2_crypto_libressl`. In previous versions it used
`libngtcp2_crypto_quictls`, shared with quictls itself (but not
compatible with).

Adapt autotools and cmake scripts to look for the new name first, and
fall back to the old one if not found.

Fallback to quictls tested OK in CI with both autotools and cmake:
https://github.com/curl/curl/actions/runs/17174994908?pr=18377

Ref: https://github.com/ngtcp2/ngtcp2/releases/tag/v1.15.0
Ref: https://github.com/ngtcp2/ngtcp2/pull/1716

Closes #18377
This commit is contained in:
Viktor Szakats 2025-08-23 10:48:12 +02:00
parent e724259bcb
commit 31e6798544
No known key found for this signature in database
GPG key ID: B5ABD165E2AEF201
5 changed files with 87 additions and 14 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`.
# - BoringSSL: Use `libngtcp2_crypto_boringssl`. (also for AWS-LC)
# - 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`. (also for LibreSSL with ngtcp2 <1.15.0)
# - 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()