mirror of
https://github.com/curl/curl.git
synced 2026-05-22 21:16:24 +03:00
cmake: export/forward NGTCP2_CRYPTO_BACKEND
Exporting the component name as passed in is somewhat boring. OTOH it is
convenient for reuse.
- FindNGTCP2: export crypto backend in `NGTCP2_CRYPTO_BACKEND`.
- pass `COMPONENTS` `NGTCP2_CRYPTO_BACKEND` in `curl-config.cmake`.
- FindNGTCP2: fix to skip Config detection when optional `COMPONENTS` is
not passed.
Co-authored-by: Viktor Szakats
Reported-by: x-xiang on github
Fixes #21523
Follow-up to 8fce3e17e6 #20814
Closes #21540
This commit is contained in:
parent
e8ce697973
commit
7d546e52b2
3 changed files with 13 additions and 12 deletions
|
|
@ -49,27 +49,28 @@
|
|||
#
|
||||
# - `NGTCP2_FOUND`: System has ngtcp2.
|
||||
# - `NGTCP2_VERSION`: Version of ngtcp2.
|
||||
# - `NGTCP2_CRYPTO_BACKEND`: Name of the crypto library component. (Empty if COMPONENTS was not used.)
|
||||
# - `CURL::ngtcp2`: ngtcp2 library target.
|
||||
|
||||
set(NGTCP2_CRYPTO_BACKEND "")
|
||||
if(NGTCP2_FIND_COMPONENTS)
|
||||
set(_ngtcp2_crypto_backend "")
|
||||
foreach(_component IN LISTS NGTCP2_FIND_COMPONENTS)
|
||||
if(_component MATCHES "^(BoringSSL|GnuTLS|LibreSSL|ossl|quictls|wolfSSL)")
|
||||
if(_ngtcp2_crypto_backend)
|
||||
if(NGTCP2_CRYPTO_BACKEND)
|
||||
message(FATAL_ERROR "NGTCP2: Only one crypto library can be selected")
|
||||
endif()
|
||||
set(_ngtcp2_crypto_backend ${_component})
|
||||
set(NGTCP2_CRYPTO_BACKEND ${_component})
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
if(_ngtcp2_crypto_backend)
|
||||
string(TOLOWER "ngtcp2_crypto_${_ngtcp2_crypto_backend}" _crypto_library_lower)
|
||||
string(TOUPPER "ngtcp2_crypto_${_ngtcp2_crypto_backend}" _crypto_library_upper)
|
||||
if(NGTCP2_CRYPTO_BACKEND)
|
||||
string(TOLOWER "ngtcp2_crypto_${NGTCP2_CRYPTO_BACKEND}" _crypto_library_lower)
|
||||
string(TOUPPER "ngtcp2_crypto_${NGTCP2_CRYPTO_BACKEND}" _crypto_library_upper)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
set(_ngtcp2_pc_requires "libngtcp2")
|
||||
if(_ngtcp2_crypto_backend)
|
||||
if(NGTCP2_CRYPTO_BACKEND)
|
||||
list(APPEND _ngtcp2_pc_requires "lib${_crypto_library_lower}")
|
||||
endif()
|
||||
|
||||
|
|
@ -81,7 +82,7 @@ if(NOT DEFINED NGTCP2_INCLUDE_DIR AND
|
|||
pkg_check_modules(_ngtcp2 ${_ngtcp2_pc_requires})
|
||||
set(_tried_pkgconfig TRUE)
|
||||
endif()
|
||||
if(NOT _ngtcp2_FOUND AND CURL_USE_CMAKECONFIG)
|
||||
if(NOT _ngtcp2_FOUND AND CURL_USE_CMAKECONFIG AND NGTCP2_CRYPTO_BACKEND)
|
||||
find_package(ngtcp2 CONFIG QUIET)
|
||||
# Skip using it if the crypto library target is not available
|
||||
if(ngtcp2_CONFIG AND
|
||||
|
|
@ -130,7 +131,7 @@ else()
|
|||
unset(_version_str)
|
||||
endif()
|
||||
|
||||
if(_ngtcp2_crypto_backend)
|
||||
if(NGTCP2_CRYPTO_BACKEND)
|
||||
if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.20)
|
||||
cmake_path(GET NGTCP2_LIBRARY PARENT_PATH _ngtcp2_library_dir)
|
||||
else()
|
||||
|
|
@ -145,7 +146,7 @@ else()
|
|||
endif()
|
||||
|
||||
if(${_crypto_library_upper}_LIBRARY)
|
||||
set(NGTCP2_${_ngtcp2_crypto_backend}_FOUND TRUE)
|
||||
set(NGTCP2_${NGTCP2_CRYPTO_BACKEND}_FOUND TRUE)
|
||||
set(NGTCP2_CRYPTO_LIBRARY ${${_crypto_library_upper}_LIBRARY})
|
||||
endif()
|
||||
endif()
|
||||
|
|
|
|||
|
|
@ -122,7 +122,7 @@ if("@USE_NGHTTP3@")
|
|||
list(APPEND _curl_libs CURL::nghttp3)
|
||||
endif()
|
||||
if("@USE_NGTCP2@")
|
||||
find_dependency(NGTCP2 MODULE)
|
||||
find_dependency(NGTCP2 MODULE COMPONENTS @NGTCP2_CRYPTO_BACKEND@)
|
||||
list(APPEND _curl_libs CURL::ngtcp2)
|
||||
endif()
|
||||
if("@USE_GNUTLS@")
|
||||
|
|
|
|||
|
|
@ -2374,7 +2374,7 @@ if(NOT CURL_DISABLE_INSTALL)
|
|||
# USE_MBEDTLS
|
||||
# USE_NGHTTP2
|
||||
# USE_NGHTTP3
|
||||
# USE_NGTCP2
|
||||
# USE_NGTCP2 NGTCP2_CRYPTO_BACKEND
|
||||
# USE_OPENSSL OPENSSL_VERSION_MAJOR
|
||||
# USE_QUICHE
|
||||
# USE_RUSTLS
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue