From: Viktor Szakats Date: Tue, 16 Dec 2025 23:11:52 +0000 (+0100) Subject: cmke: add `*_USE_STATIC_LIBS` options for 9 dependencies X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=26c39d8df182a63d28d81ed2b044e6a343519d1a;p=thirdparty%2Fcurl.git cmke: add `*_USE_STATIC_LIBS` options for 9 dependencies Via options: - `BROTLI_USE_STATIC_LIBS` - `CARES_USE_STATIC_LIBS` - `LIBSSH_USE_STATIC_LIBS` - `LIBSSH2_USE_STATIC_LIBS` - `MBEDTLS_USE_STATIC_LIBS` - `NGHTTP2_USE_STATIC_LIBS` - `NGHTTP3_USE_STATIC_LIBS` - `NGTCP2_USE_STATIC_LIBS` - `ZSTD_USE_STATIC_LIBS` When enabled, make a "best effort" finding static libs first and set the "build static" macro (on Windows) as required by the dependency. When doing `pkg-config`-based detections, make curl select the static configuration, which shall set the "build static" macro also. These options resemble CMake's `OPENSSL_USE_STATIC_LIBS` and `ZLIB_USE_STATIC_LIBS` (the latter does not support `pkg-config` as of CMake v4.2.2). Shared/static library selection based on loose filename conventions is fragile and prone to break if the non-static-suffixed library is found and happens to be a shared library, or, if the linker decides to pick up a shared copy (e.g. `.a.dll`) that shadows the static one. It may help to provide either static or shared, but not both, on the disk, and match that with this setting. Experimental. Ref: #20013 Closes #20015 --- diff --git a/CMake/FindBrotli.cmake b/CMake/FindBrotli.cmake index 981b30cafd..b5437e7525 100644 --- a/CMake/FindBrotli.cmake +++ b/CMake/FindBrotli.cmake @@ -25,15 +25,16 @@ # # Input variables: # -# - `BROTLI_INCLUDE_DIR`: Absolute path to brotli include directory. -# - `BROTLICOMMON_LIBRARY`: Absolute path to `brotlicommon` library. -# - `BROTLIDEC_LIBRARY`: Absolute path to `brotlidec` library. +# - `BROTLI_INCLUDE_DIR`: Absolute path to brotli include directory. +# - `BROTLICOMMON_LIBRARY`: Absolute path to `brotlicommon` library. +# - `BROTLIDEC_LIBRARY`: Absolute path to `brotlidec` library. +# - `BROTLI_USE_STATIC_LIBS`: Configure for static brotli libraries. # # Defines: # -# - `BROTLI_FOUND`: System has brotli. -# - `BROTLI_VERSION`: Version of brotli. -# - `CURL::brotli`: brotli library target. +# - `BROTLI_FOUND`: System has brotli. +# - `BROTLI_VERSION`: Version of brotli. +# - `CURL::brotli`: brotli library target. set(_brotli_pc_requires "libbrotlidec" "libbrotlicommon") # order is significant: brotlidec then brotlicommon @@ -49,11 +50,22 @@ if(_brotli_FOUND) set(Brotli_FOUND TRUE) set(BROTLI_FOUND TRUE) set(BROTLI_VERSION ${_brotli_libbrotlicommon_VERSION}) + if(BROTLI_USE_STATIC_LIBS) + set(_brotli_CFLAGS "${_brotli_STATIC_CFLAGS}") + set(_brotli_INCLUDE_DIRS "${_brotli_STATIC_INCLUDE_DIRS}") + set(_brotli_LIBRARY_DIRS "${_brotli_STATIC_LIBRARY_DIRS}") + set(_brotli_LIBRARIES "${_brotli_STATIC_LIBRARIES}") + endif() message(STATUS "Found Brotli (via pkg-config): ${_brotli_INCLUDE_DIRS} (found version \"${BROTLI_VERSION}\")") else() find_path(BROTLI_INCLUDE_DIR "brotli/decode.h") - find_library(BROTLICOMMON_LIBRARY NAMES "brotlicommon") - find_library(BROTLIDEC_LIBRARY NAMES "brotlidec") + if(BROTLI_USE_STATIC_LIBS) + find_library(BROTLICOMMON_LIBRARY NAMES "brotlicommon-static" "brotlicommon") + find_library(BROTLIDEC_LIBRARY NAMES "brotlidec-static" "brotlidec") + else() + find_library(BROTLICOMMON_LIBRARY NAMES "brotlicommon") + find_library(BROTLIDEC_LIBRARY NAMES "brotlidec") + endif() include(FindPackageHandleStandardArgs) find_package_handle_standard_args(Brotli diff --git a/CMake/FindCares.cmake b/CMake/FindCares.cmake index 4a20bc0af4..3c05c3b2eb 100644 --- a/CMake/FindCares.cmake +++ b/CMake/FindCares.cmake @@ -25,14 +25,15 @@ # # Input variables: # -# - `CARES_INCLUDE_DIR`: Absolute path to c-ares include directory. -# - `CARES_LIBRARY`: Absolute path to `cares` library. +# - `CARES_INCLUDE_DIR`: Absolute path to c-ares include directory. +# - `CARES_LIBRARY`: Absolute path to `cares` library. +# - `CARES_USE_STATIC_LIBS`: Configure for static c-ares libraries. # # Defines: # -# - `CARES_FOUND`: System has c-ares. -# - `CARES_VERSION`: Version of c-ares. -# - `CURL::cares`: c-ares library target. +# - `CARES_FOUND`: System has c-ares. +# - `CARES_VERSION`: Version of c-ares. +# - `CURL::cares`: c-ares library target. set(_cares_pc_requires "libcares") @@ -47,10 +48,21 @@ if(_cares_FOUND) set(Cares_FOUND TRUE) set(CARES_FOUND TRUE) set(CARES_VERSION ${_cares_VERSION}) + if(CARES_USE_STATIC_LIBS) + set(_cares_CFLAGS "${_cares_STATIC_CFLAGS}") + set(_cares_INCLUDE_DIRS "${_cares_STATIC_INCLUDE_DIRS}") + set(_cares_LIBRARY_DIRS "${_cares_STATIC_LIBRARY_DIRS}") + set(_cares_LIBRARIES "${_cares_STATIC_LIBRARIES}") + endif() message(STATUS "Found Cares (via pkg-config): ${_cares_INCLUDE_DIRS} (found version \"${CARES_VERSION}\")") else() find_path(CARES_INCLUDE_DIR NAMES "ares.h") - find_library(CARES_LIBRARY NAMES ${CARES_NAMES} "cares") + if(CARES_USE_STATIC_LIBS) + set(_cares_CFLAGS "-DCARES_STATICLIB") + find_library(CARES_LIBRARY NAMES ${CARES_NAMES} "cares_static" "cares") + else() + find_library(CARES_LIBRARY NAMES ${CARES_NAMES} "cares") + endif() unset(CARES_VERSION CACHE) if(CARES_INCLUDE_DIR AND EXISTS "${CARES_INCLUDE_DIR}/ares_version.h") diff --git a/CMake/FindLibssh.cmake b/CMake/FindLibssh.cmake index ad1248fe00..732ab8ee27 100644 --- a/CMake/FindLibssh.cmake +++ b/CMake/FindLibssh.cmake @@ -25,14 +25,15 @@ # # Input variables: # -# - `LIBSSH_INCLUDE_DIR`: Absolute path to libssh include directory. -# - `LIBSSH_LIBRARY`: Absolute path to `libssh` library. +# - `LIBSSH_INCLUDE_DIR`: Absolute path to libssh include directory. +# - `LIBSSH_LIBRARY`: Absolute path to `libssh` library. +# - `LIBSSH_USE_STATIC_LIBS`: Configure for static libssh libraries. # # Defines: # -# - `LIBSSH_FOUND`: System has libssh. -# - `LIBSSH_VERSION`: Version of libssh. -# - `CURL::libssh`: libssh library target. +# - `LIBSSH_FOUND`: System has libssh. +# - `LIBSSH_VERSION`: Version of libssh. +# - `CURL::libssh`: libssh library target. set(_libssh_pc_requires "libssh") @@ -47,10 +48,21 @@ if(_libssh_FOUND) set(Libssh_FOUND TRUE) set(LIBSSH_FOUND TRUE) set(LIBSSH_VERSION ${_libssh_VERSION}) + if(LIBSSH_USE_STATIC_LIBS) + set(_libssh_CFLAGS "${_libssh_STATIC_CFLAGS}") + set(_libssh_INCLUDE_DIRS "${_libssh_STATIC_INCLUDE_DIRS}") + set(_libssh_LIBRARY_DIRS "${_libssh_STATIC_LIBRARY_DIRS}") + set(_libssh_LIBRARIES "${_libssh_STATIC_LIBRARIES}") + endif() message(STATUS "Found Libssh (via pkg-config): ${_libssh_INCLUDE_DIRS} (found version \"${LIBSSH_VERSION}\")") else() find_path(LIBSSH_INCLUDE_DIR NAMES "libssh/libssh.h") - find_library(LIBSSH_LIBRARY NAMES "ssh" "libssh") + if(LIBSSH_USE_STATIC_LIBS) + set(_libssh_CFLAGS "-DLIBSSH_STATIC") + find_library(LIBSSH_LIBRARY NAMES "ssh_static" "libssh_static" "ssh" "libssh") + else() + find_library(LIBSSH_LIBRARY NAMES "ssh" "libssh") + endif() unset(LIBSSH_VERSION CACHE) if(LIBSSH_INCLUDE_DIR AND EXISTS "${LIBSSH_INCLUDE_DIR}/libssh/libssh_version.h") diff --git a/CMake/FindLibssh2.cmake b/CMake/FindLibssh2.cmake index 330611bfe5..abed471eb2 100644 --- a/CMake/FindLibssh2.cmake +++ b/CMake/FindLibssh2.cmake @@ -25,14 +25,15 @@ # # Input variables: # -# - `LIBSSH2_INCLUDE_DIR`: Absolute path to libssh2 include directory. -# - `LIBSSH2_LIBRARY`: Absolute path to `libssh2` library. +# - `LIBSSH2_INCLUDE_DIR`: Absolute path to libssh2 include directory. +# - `LIBSSH2_LIBRARY`: Absolute path to `libssh2` library. +# - `LIBSSH2_USE_STATIC_LIBS`: Configure for static libssh2 libraries. # # Defines: # -# - `LIBSSH2_FOUND`: System has libssh2. -# - `LIBSSH2_VERSION`: Version of libssh2. -# - `CURL::libssh2`: libssh2 library target. +# - `LIBSSH2_FOUND`: System has libssh2. +# - `LIBSSH2_VERSION`: Version of libssh2. +# - `CURL::libssh2`: libssh2 library target. set(_libssh2_pc_requires "libssh2") @@ -47,10 +48,20 @@ if(_libssh2_FOUND AND _libssh2_INCLUDE_DIRS) set(Libssh2_FOUND TRUE) set(LIBSSH2_FOUND TRUE) set(LIBSSH2_VERSION ${_libssh2_VERSION}) + if(LIBSSH2_USE_STATIC_LIBS) + set(_libssh2_CFLAGS "${_libssh2_STATIC_CFLAGS}") + set(_libssh2_INCLUDE_DIRS "${_libssh2_STATIC_INCLUDE_DIRS}") + set(_libssh2_LIBRARY_DIRS "${_libssh2_STATIC_LIBRARY_DIRS}") + set(_libssh2_LIBRARIES "${_libssh2_STATIC_LIBRARIES}") + endif() message(STATUS "Found Libssh2 (via pkg-config): ${_libssh2_INCLUDE_DIRS} (found version \"${LIBSSH2_VERSION}\")") else() find_path(LIBSSH2_INCLUDE_DIR NAMES "libssh2.h") - find_library(LIBSSH2_LIBRARY NAMES "ssh2" "libssh2") + if(LIBSSH2_USE_STATIC_LIBS) + find_library(LIBSSH2_LIBRARY NAMES "ssh2_static" "libssh2_static" "ssh2" "libssh2") + else() + find_library(LIBSSH2_LIBRARY NAMES "ssh2" "libssh2") + endif() unset(LIBSSH2_VERSION CACHE) if(LIBSSH2_INCLUDE_DIR AND EXISTS "${LIBSSH2_INCLUDE_DIR}/libssh2.h") diff --git a/CMake/FindMbedTLS.cmake b/CMake/FindMbedTLS.cmake index 97201ab2b3..986f187802 100644 --- a/CMake/FindMbedTLS.cmake +++ b/CMake/FindMbedTLS.cmake @@ -25,16 +25,17 @@ # # Input variables: # -# - `MBEDTLS_INCLUDE_DIR`: Absolute path to mbedTLS include directory. -# - `MBEDTLS_LIBRARY`: Absolute path to `mbedtls` library. -# - `MBEDX509_LIBRARY`: Absolute path to `mbedx509` library. -# - `MBEDCRYPTO_LIBRARY`: Absolute path to `mbedcrypto` library. +# - `MBEDTLS_INCLUDE_DIR`: Absolute path to mbedTLS include directory. +# - `MBEDTLS_LIBRARY`: Absolute path to `mbedtls` library. +# - `MBEDX509_LIBRARY`: Absolute path to `mbedx509` library. +# - `MBEDCRYPTO_LIBRARY`: Absolute path to `mbedcrypto` library. +# - `MBEDTLS_USE_STATIC_LIBS`: Configure for static mbedTLS libraries. # # Defines: # -# - `MBEDTLS_FOUND`: System has mbedTLS. -# - `MBEDTLS_VERSION`: Version of mbedTLS. -# - `CURL::mbedtls`: mbedTLS library target. +# - `MBEDTLS_FOUND`: System has mbedTLS. +# - `MBEDTLS_VERSION`: Version of mbedTLS. +# - `CURL::mbedtls`: mbedTLS library target. if(DEFINED MBEDTLS_INCLUDE_DIRS AND NOT DEFINED MBEDTLS_INCLUDE_DIR) message(WARNING "MBEDTLS_INCLUDE_DIRS is deprecated, use MBEDTLS_INCLUDE_DIR instead.") @@ -57,14 +58,26 @@ if(_mbedtls_FOUND) set(MbedTLS_FOUND TRUE) set(MBEDTLS_FOUND TRUE) set(MBEDTLS_VERSION ${_mbedtls_mbedtls_VERSION}) + if(MBEDTLS_USE_STATIC_LIBS) + set(_mbedtls_CFLAGS "${_mbedtls_STATIC_CFLAGS}") + set(_mbedtls_INCLUDE_DIRS "${_mbedtls_STATIC_INCLUDE_DIRS}") + set(_mbedtls_LIBRARY_DIRS "${_mbedtls_STATIC_LIBRARY_DIRS}") + set(_mbedtls_LIBRARIES "${_mbedtls_STATIC_LIBRARIES}") + endif() message(STATUS "Found MbedTLS (via pkg-config): ${_mbedtls_INCLUDE_DIRS} (found version \"${MBEDTLS_VERSION}\")") else() set(_mbedtls_pc_requires "") # Depend on pkg-config only when found via pkg-config find_path(MBEDTLS_INCLUDE_DIR NAMES "mbedtls/ssl.h") - find_library(MBEDTLS_LIBRARY NAMES "mbedtls" "libmbedtls") - find_library(MBEDX509_LIBRARY NAMES "mbedx509" "libmbedx509") - find_library(MBEDCRYPTO_LIBRARY NAMES "mbedcrypto" "libmbedcrypto") + if(MBEDTLS_USE_STATIC_LIBS) + find_library(MBEDTLS_LIBRARY NAMES "mbedtls_static" "libmbedtls_static" "mbedtls" "libmbedtls") + find_library(MBEDX509_LIBRARY NAMES "mbedx509_static" "libmbedx509_static" "mbedx509" "libmbedx509") + find_library(MBEDCRYPTO_LIBRARY NAMES "mbedcrypto_static" "libmbedcrypto_static" "mbedcrypto" "libmbedcrypto") + else() + find_library(MBEDTLS_LIBRARY NAMES "mbedtls" "libmbedtls") + find_library(MBEDX509_LIBRARY NAMES "mbedx509" "libmbedx509") + find_library(MBEDCRYPTO_LIBRARY NAMES "mbedcrypto" "libmbedcrypto") + endif() unset(MBEDTLS_VERSION CACHE) if(MBEDTLS_INCLUDE_DIR AND EXISTS "${MBEDTLS_INCLUDE_DIR}/mbedtls/build_info.h") diff --git a/CMake/FindNGHTTP2.cmake b/CMake/FindNGHTTP2.cmake index 8304345a38..b2a8c97ccd 100644 --- a/CMake/FindNGHTTP2.cmake +++ b/CMake/FindNGHTTP2.cmake @@ -25,14 +25,15 @@ # # Input variables: # -# - `NGHTTP2_INCLUDE_DIR`: Absolute path to nghttp2 include directory. -# - `NGHTTP2_LIBRARY`: Absolute path to `nghttp2` library. +# - `NGHTTP2_INCLUDE_DIR`: Absolute path to nghttp2 include directory. +# - `NGHTTP2_LIBRARY`: Absolute path to `nghttp2` library. +# - `NGHTTP2_USE_STATIC_LIBS`: Configure for static nghttp2 libraries. # # Defines: # -# - `NGHTTP2_FOUND`: System has nghttp2. -# - `NGHTTP2_VERSION`: Version of nghttp2. -# - `CURL::nghttp2`: nghttp2 library target. +# - `NGHTTP2_FOUND`: System has nghttp2. +# - `NGHTTP2_VERSION`: Version of nghttp2. +# - `CURL::nghttp2`: nghttp2 library target. set(_nghttp2_pc_requires "libnghttp2") @@ -46,10 +47,21 @@ endif() if(_nghttp2_FOUND) set(NGHTTP2_FOUND TRUE) set(NGHTTP2_VERSION ${_nghttp2_VERSION}) + if(NGHTTP2_USE_STATIC_LIBS) + set(_nghttp2_CFLAGS "${_nghttp2_STATIC_CFLAGS}") + set(_nghttp2_INCLUDE_DIRS "${_nghttp2_STATIC_INCLUDE_DIRS}") + set(_nghttp2_LIBRARY_DIRS "${_nghttp2_STATIC_LIBRARY_DIRS}") + set(_nghttp2_LIBRARIES "${_nghttp2_STATIC_LIBRARIES}") + endif() message(STATUS "Found NGHTTP2 (via pkg-config): ${_nghttp2_INCLUDE_DIRS} (found version \"${NGHTTP2_VERSION}\")") else() find_path(NGHTTP2_INCLUDE_DIR NAMES "nghttp2/nghttp2.h") - find_library(NGHTTP2_LIBRARY NAMES "nghttp2" "nghttp2_static") + if(NGHTTP2_USE_STATIC_LIBS) + set(_nghttp2_CFLAGS "-DNGHTTP2_STATICLIB") + find_library(NGHTTP2_LIBRARY NAMES "nghttp2_static" "nghttp2") + else() + find_library(NGHTTP2_LIBRARY NAMES "nghttp2" "nghttp2_static") + endif() unset(NGHTTP2_VERSION CACHE) if(NGHTTP2_INCLUDE_DIR AND EXISTS "${NGHTTP2_INCLUDE_DIR}/nghttp2/nghttp2ver.h") diff --git a/CMake/FindNGHTTP3.cmake b/CMake/FindNGHTTP3.cmake index 37ebfe1114..57550bffaf 100644 --- a/CMake/FindNGHTTP3.cmake +++ b/CMake/FindNGHTTP3.cmake @@ -25,14 +25,15 @@ # # Input variables: # -# - `NGHTTP3_INCLUDE_DIR`: Absolute path to nghttp3 include directory. -# - `NGHTTP3_LIBRARY`: Absolute path to `nghttp3` library. +# - `NGHTTP3_INCLUDE_DIR`: Absolute path to nghttp3 include directory. +# - `NGHTTP3_LIBRARY`: Absolute path to `nghttp3` library. +# - `NGHTTP3_USE_STATIC_LIBS`: Configure for static nghttp3 libraries. # # Defines: # -# - `NGHTTP3_FOUND`: System has nghttp3. -# - `NGHTTP3_VERSION`: Version of nghttp3. -# - `CURL::nghttp3`: nghttp3 library target. +# - `NGHTTP3_FOUND`: System has nghttp3. +# - `NGHTTP3_VERSION`: Version of nghttp3. +# - `CURL::nghttp3`: nghttp3 library target. set(_nghttp3_pc_requires "libnghttp3") @@ -46,10 +47,21 @@ endif() if(_nghttp3_FOUND) set(NGHTTP3_FOUND TRUE) set(NGHTTP3_VERSION ${_nghttp3_VERSION}) + if(NGHTTP3_USE_STATIC_LIBS) + set(_nghttp3_CFLAGS "${_nghttp3_STATIC_CFLAGS}") + set(_nghttp3_INCLUDE_DIRS "${_nghttp3_STATIC_INCLUDE_DIRS}") + set(_nghttp3_LIBRARY_DIRS "${_nghttp3_STATIC_LIBRARY_DIRS}") + set(_nghttp3_LIBRARIES "${_nghttp3_STATIC_LIBRARIES}") + endif() message(STATUS "Found NGHTTP3 (via pkg-config): ${_nghttp3_INCLUDE_DIRS} (found version \"${NGHTTP3_VERSION}\")") else() find_path(NGHTTP3_INCLUDE_DIR NAMES "nghttp3/nghttp3.h") - find_library(NGHTTP3_LIBRARY NAMES "nghttp3") + if(NGHTTP3_USE_STATIC_LIBS) + set(_nghttp3_CFLAGS "-DNGHTTP3_STATICLIB") + find_library(NGHTTP3_LIBRARY NAMES "nghttp3_static" "nghttp3") + else() + find_library(NGHTTP3_LIBRARY NAMES "nghttp3") + endif() unset(NGHTTP3_VERSION CACHE) if(NGHTTP3_INCLUDE_DIR AND EXISTS "${NGHTTP3_INCLUDE_DIR}/nghttp3/version.h") diff --git a/CMake/FindNGTCP2.cmake b/CMake/FindNGTCP2.cmake index 416ea459f6..615ee4a3c2 100644 --- a/CMake/FindNGTCP2.cmake +++ b/CMake/FindNGTCP2.cmake @@ -43,6 +43,7 @@ # - `NGTCP2_CRYPTO_OSSL_LIBRARY`: Absolute path to `ngtcp2_crypto_ossl` library. # - `NGTCP2_CRYPTO_QUICTLS_LIBRARY`: Absolute path to `ngtcp2_crypto_quictls` library. # - `NGTCP2_CRYPTO_WOLFSSL_LIBRARY`: Absolute path to `ngtcp2_crypto_wolfssl` library. +# - `NGTCP2_USE_STATIC_LIBS`: Configure for static ngtcp2 libraries. # # Defines: # @@ -84,10 +85,21 @@ endif() if(_ngtcp2_FOUND) set(NGTCP2_FOUND TRUE) set(NGTCP2_VERSION ${_ngtcp2_libngtcp2_VERSION}) + if(NGTCP2_USE_STATIC_LIBS) + set(_ngtcp2_CFLAGS "${_ngtcp2_STATIC_CFLAGS}") + set(_ngtcp2_INCLUDE_DIRS "${_ngtcp2_STATIC_INCLUDE_DIRS}") + set(_ngtcp2_LIBRARY_DIRS "${_ngtcp2_STATIC_LIBRARY_DIRS}") + set(_ngtcp2_LIBRARIES "${_ngtcp2_STATIC_LIBRARIES}") + endif() message(STATUS "Found NGTCP2 (via pkg-config): ${_ngtcp2_INCLUDE_DIRS} (found version \"${NGTCP2_VERSION}\")") else() find_path(NGTCP2_INCLUDE_DIR NAMES "ngtcp2/ngtcp2.h") - find_library(NGTCP2_LIBRARY NAMES "ngtcp2") + if(NGTCP2_USE_STATIC_LIBS) + set(_ngtcp2_CFLAGS "-DNGTCP2_STATICLIB") + find_library(NGTCP2_LIBRARY NAMES "ngtcp2_static" "ngtcp2") + else() + find_library(NGTCP2_LIBRARY NAMES "ngtcp2") + endif() unset(NGTCP2_VERSION CACHE) if(NGTCP2_INCLUDE_DIR AND EXISTS "${NGTCP2_INCLUDE_DIR}/ngtcp2/version.h") @@ -105,7 +117,13 @@ else() else() get_filename_component(_ngtcp2_library_dir "${NGTCP2_LIBRARY}" DIRECTORY) endif() - find_library(${_crypto_library_upper}_LIBRARY NAMES ${_crypto_library_lower} HINTS ${_ngtcp2_library_dir}) + if(NGTCP2_USE_STATIC_LIBS) + find_library(${_crypto_library_upper}_LIBRARY NAMES ${_crypto_library_lower}_static ${_crypto_library_lower} + HINTS ${_ngtcp2_library_dir}) + else() + find_library(${_crypto_library_upper}_LIBRARY NAMES ${_crypto_library_lower} + HINTS ${_ngtcp2_library_dir}) + endif() if(${_crypto_library_upper}_LIBRARY) set(NGTCP2_${_ngtcp2_crypto_backend}_FOUND TRUE) diff --git a/CMake/FindZstd.cmake b/CMake/FindZstd.cmake index 954a827b6f..baf6148f0d 100644 --- a/CMake/FindZstd.cmake +++ b/CMake/FindZstd.cmake @@ -25,14 +25,15 @@ # # Input variables: # -# - `ZSTD_INCLUDE_DIR`: Absolute path to zstd include directory. -# - `ZSTD_LIBRARY`: Absolute path to `zstd` library. +# - `ZSTD_INCLUDE_DIR`: Absolute path to zstd include directory. +# - `ZSTD_LIBRARY`: Absolute path to `zstd` library. +# - `ZSTD_USE_STATIC_LIBS`: Configure for static zstd libraries. # # Defines: # -# - `ZSTD_FOUND`: System has zstd. -# - `ZSTD_VERSION`: Version of zstd. -# - `CURL::zstd`: zstd library target. +# - `ZSTD_FOUND`: System has zstd. +# - `ZSTD_VERSION`: Version of zstd. +# - `CURL::zstd`: zstd library target. if(DEFINED Zstd_INCLUDE_DIR AND NOT DEFINED ZSTD_INCLUDE_DIR) message(WARNING "Zstd_INCLUDE_DIR is deprecated, use ZSTD_INCLUDE_DIR instead.") @@ -56,10 +57,20 @@ if(_zstd_FOUND) set(Zstd_FOUND TRUE) set(ZSTD_FOUND TRUE) set(ZSTD_VERSION ${_zstd_VERSION}) + if(ZSTD_USE_STATIC_LIBS) + set(_zstd_CFLAGS "${_zstd_STATIC_CFLAGS}") + set(_zstd_INCLUDE_DIRS "${_zstd_STATIC_INCLUDE_DIRS}") + set(_zstd_LIBRARY_DIRS "${_zstd_STATIC_LIBRARY_DIRS}") + set(_zstd_LIBRARIES "${_zstd_STATIC_LIBRARIES}") + endif() message(STATUS "Found Zstd (via pkg-config): ${_zstd_INCLUDE_DIRS} (found version \"${ZSTD_VERSION}\")") else() find_path(ZSTD_INCLUDE_DIR NAMES "zstd.h") - find_library(ZSTD_LIBRARY NAMES "zstd") + if(ZSTD_USE_STATIC_LIBS) + find_library(ZSTD_LIBRARY NAMES "zstd_static" "zstd") + else() + find_library(ZSTD_LIBRARY NAMES "zstd") + endif() unset(ZSTD_VERSION CACHE) if(ZSTD_INCLUDE_DIR AND EXISTS "${ZSTD_INCLUDE_DIR}/zstd.h") diff --git a/docs/INSTALL-CMAKE.md b/docs/INSTALL-CMAKE.md index d61014f9e5..4f4ba9d51d 100644 --- a/docs/INSTALL-CMAKE.md +++ b/docs/INSTALL-CMAKE.md @@ -409,8 +409,10 @@ Details via CMake - `BROTLI_INCLUDE_DIR`: Absolute path to brotli include directory. - `BROTLICOMMON_LIBRARY`: Absolute path to `brotlicommon` library. - `BROTLIDEC_LIBRARY`: Absolute path to `brotlidec` library. +- `BROTLI_USE_STATIC_LIBS`: Configure for static brotli libraries. - `CARES_INCLUDE_DIR`: Absolute path to c-ares include directory. - `CARES_LIBRARY`: Absolute path to `cares` library. +- `CARES_USE_STATIC_LIBS`: Configure for static c-ares libraries. - `DL_LIBRARY`: Absolute path to `dl` library. (for Rustls) - `GNUTLS_INCLUDE_DIR`: Absolute path to GnuTLS include directory. - `GNUTLS_LIBRARY`: Absolute path to `gnutls` library. @@ -430,8 +432,10 @@ Details via CMake - `LIBRTMP_LIBRARY`: Absolute path to `librtmp` library. - `LIBSSH_INCLUDE_DIR`: Absolute path to libssh include directory. - `LIBSSH_LIBRARY`: Absolute path to `libssh` library. +- `LIBSSH_USE_STATIC_LIBS`: Configure for static libssh libraries. - `LIBSSH2_INCLUDE_DIR`: Absolute path to libssh2 include directory. - `LIBSSH2_LIBRARY`: Absolute path to `libssh2` library. +- `LIBSSH2_USE_STATIC_LIBS`: Configure for static libssh2 libraries. - `LIBUV_INCLUDE_DIR`: Absolute path to libuv include directory. - `LIBUV_LIBRARY`: Absolute path to `libuv` library. - `MATH_LIBRARY`: Absolute path to `m` library. (for Rustls, wolfSSL) @@ -439,10 +443,13 @@ Details via CMake - `MBEDTLS_LIBRARY`: Absolute path to `mbedtls` library. - `MBEDX509_LIBRARY`: Absolute path to `mbedx509` library. - `MBEDCRYPTO_LIBRARY`: Absolute path to `mbedcrypto` library. +- `MBEDTLS_USE_STATIC_LIBS`: Configure for static mbedTLS libraries. - `NGHTTP2_INCLUDE_DIR`: Absolute path to nghttp2 include directory. - `NGHTTP2_LIBRARY`: Absolute path to `nghttp2` library. +- `NGHTTP2_USE_STATIC_LIBS`: Configure for static nghttp2 libraries. - `NGHTTP3_INCLUDE_DIR`: Absolute path to nghttp3 include directory. - `NGHTTP3_LIBRARY`: Absolute path to `nghttp3` library. +- `NGHTTP3_USE_STATIC_LIBS`: Configure for static nghttp3 libraries. - `NGTCP2_INCLUDE_DIR`: Absolute path to ngtcp2 include directory. - `NGTCP2_LIBRARY`: Absolute path to `ngtcp2` library. - `NGTCP2_CRYPTO_BORINGSSL_LIBRARY`: Absolute path to `ngtcp2_crypto_boringssl` library. (also for AWS-LC) @@ -451,6 +458,7 @@ Details via CMake - `NGTCP2_CRYPTO_OSSL_LIBRARY`: Absolute path to `ngtcp2_crypto_ossl` library. - `NGTCP2_CRYPTO_QUICTLS_LIBRARY`: Absolute path to `ngtcp2_crypto_quictls` library. (also for LibreSSL with ngtcp2 <1.15.0) - `NGTCP2_CRYPTO_WOLFSSL_LIBRARY`: Absolute path to `ngtcp2_crypto_wolfssl` library. +- `NGTCP2_USE_STATIC_LIBS`: Configure for static ngtcp2 libraries. - `NETTLE_INCLUDE_DIR`: Absolute path to nettle include directory. - `NETTLE_LIBRARY`: Absolute path to `nettle` library. - `PTHREAD_LIBRARY`: Absolute path to `pthread` library. (for Rustls) @@ -463,6 +471,7 @@ Details via CMake - `WOLFSSL_LIBRARY`: Absolute path to `wolfssl` library. - `ZSTD_INCLUDE_DIR`: Absolute path to zstd include directory. - `ZSTD_LIBRARY`: Absolute path to `zstd` library. +- `ZSTD_USE_STATIC_LIBS`: Configure for static zstd libraries. Examples: