cmake: add native pkg-config detection for mbedTLS, MSH3, Quiche, Rustls, wolfSSL

Also:
- detect and add required system libraries for Rustls on macOS and
  non-Windows.
- add Linux CMake jobs for the touched dependencies.
  Caveats:
  - MSH3 generates a broken `libmsh3.pc`, so needs manual config.
    Upstream PR: https://github.com/nibanks/msh3/pull/225
  - Rustls `.pc` file missing, so needs manual config.

An internal change worthy of mention is that we are using the lib path
and name information returned by `pkg-config` as-is. Meaning the libname
doesn't include the full path, like it's usual with native cmake
detection. The path comes separately and needs to be rolled separately.
For this we add it to targets via `link_directories()`. We also keep tab
of them in `CURL_LIBDIRS` and use that in `libcurl.pc`. Feature checks
also need to receive these paths. CMake doesn't offer
a `CMAKE_REQUIRED_*` variable for this purpose, only
a `CMAKE_REQUIRED_LINK_OPTIONS` accepting raw linker flags. Add a macro
to convert a list of paths to linker options to solve it. wolfSSL
requires this for now.

Closes #15193
This commit is contained in:
Viktor Szakats 2024-10-08 12:32:52 +02:00
parent ae5351696f
commit 7bab201abe
No known key found for this signature in database
GPG Key ID: B5ABD165E2AEF201
9 changed files with 282 additions and 198 deletions

View File

@ -261,29 +261,40 @@ jobs:
matrix:
build:
- name: quictls
PKG_CONFIG_PATH: '$HOME/quictls/build/lib/pkgconfig:$HOME/nghttp3/build/lib/pkgconfig:$HOME/ngtcp2/build/lib/pkgconfig:$HOME/nghttp2/build/lib/pkgconfig'
configure: >-
PKG_CONFIG_PATH="$HOME/quictls/build/lib/pkgconfig:$HOME/nghttp3/build/lib/pkgconfig:$HOME/ngtcp2/build/lib/pkgconfig:$HOME/nghttp2/build/lib/pkgconfig" LDFLAGS="-Wl,-rpath,$HOME/quictls/build/lib"
LDFLAGS="-Wl,-rpath,$HOME/quictls/build/lib"
--with-ngtcp2=$HOME/ngtcp2/build --enable-warnings --enable-werror --enable-debug --disable-ntlm
--with-test-nghttpx="$HOME/nghttp2/build/bin/nghttpx"
--with-openssl=$HOME/quictls/build
- name: gnutls
PKG_CONFIG_PATH: '$HOME/gnutls/build/lib/pkgconfig:$HOME/nghttp3/build/lib/pkgconfig:$HOME/ngtcp2/build/lib/pkgconfig:$HOME/nghttp2/build/lib/pkgconfig'
configure: >-
PKG_CONFIG_PATH="$HOME/gnutls/build/lib/pkgconfig:$HOME/nghttp3/build/lib/pkgconfig:$HOME/ngtcp2/build/lib/pkgconfig:$HOME/nghttp2/build/lib/pkgconfig" LDFLAGS="-Wl,-rpath,$HOME/gnutls/build/lib"
LDFLAGS="-Wl,-rpath,$HOME/gnutls/build/lib"
--with-ngtcp2=$HOME/ngtcp2/build --enable-warnings --enable-werror --enable-debug
--with-test-nghttpx="$HOME/nghttp2/build/bin/nghttpx"
--with-gnutls=$HOME/gnutls/build
- name: wolfssl
PKG_CONFIG_PATH: '$HOME/wolfssl/build/lib/pkgconfig:$HOME/nghttp3/build/lib/pkgconfig:$HOME/ngtcp2/build/lib/pkgconfig:$HOME/nghttp2/build/lib/pkgconfig'
configure: >-
PKG_CONFIG_PATH="$HOME/wolfssl/build/lib/pkgconfig:$HOME/nghttp3/build/lib/pkgconfig:$HOME/ngtcp2/build/lib/pkgconfig:$HOME/nghttp2/build/lib/pkgconfig" LDFLAGS="-Wl,-rpath,$HOME/wolfssl/build/lib"
LDFLAGS="-Wl,-rpath,$HOME/wolfssl/build/lib"
--with-ngtcp2=$HOME/ngtcp2/build --enable-warnings --enable-werror --enable-debug
--with-test-nghttpx="$HOME/nghttp2/build/bin/nghttpx"
--with-wolfssl=$HOME/wolfssl/build
- name: wolfssl
PKG_CONFIG_PATH: '$HOME/wolfssl/build/lib/pkgconfig:$HOME/nghttp3/build/lib/pkgconfig:$HOME/ngtcp2/build/lib/pkgconfig:$HOME/nghttp2/build/lib/pkgconfig'
generate: >-
-DCURL_USE_WOLFSSL=ON -DUSE_NGTCP2=ON -DENABLE_DEBUG=ON
-DTEST_NGHTTPX="$HOME/nghttp2/build/bin/nghttpx"
-DHTTPD_NGHTTPX="$HOME/nghttp2/build/bin/nghttpx"
- name: openssl-quic
PKG_CONFIG_PATH: '$HOME/openssl3/build/lib64/pkgconfig'
configure: >-
PKG_CONFIG_PATH="$HOME/openssl3/build/lib64/pkgconfig" LDFLAGS="-Wl,-rpath,$HOME/openssl3/build/lib64"
LDFLAGS="-Wl,-rpath,$HOME/openssl3/build/lib64"
--enable-warnings --enable-werror --enable-debug --disable-ntlm
--with-test-nghttpx="$HOME/nghttp2/build/bin/nghttpx"
--with-openssl=$HOME/openssl3/build --with-openssl-quic
@ -298,6 +309,15 @@ jobs:
--with-test-nghttpx="$HOME/nghttp2/build/bin/nghttpx"
--with-ca-fallback
- name: quiche
PKG_CONFIG_PATH: '$HOME/quiche/target/release'
generate: >-
-DOPENSSL_ROOT_DIR=$HOME/quiche/quiche/deps/boringssl/src -DENABLE_DEBUG=ON
-DUSE_QUICHE=ON
-DTEST_NGHTTPX="$HOME/nghttp2/build/bin/nghttpx"
-DHTTPD_NGHTTPX="$HOME/nghttp2/build/bin/nghttpx"
-DCURL_CA_FALLBACK=ON
steps:
- run: |
sudo rm -f /etc/apt/sources.list.d/microsoft-prod.list
@ -460,6 +480,9 @@ jobs:
- name: 'configure'
run: |
if [ -n '${{ matrix.build.PKG_CONFIG_PATH }}' ]; then
export PKG_CONFIG_PATH="${{ matrix.build.PKG_CONFIG_PATH }}"
fi
if [ -n '${{ matrix.build.generate }}' ]; then
cmake -B . -G Ninja \
-DCMAKE_C_COMPILER_TARGET=$(uname -m)-pc-linux-gnu -DBUILD_STATIC_LIBS=ON \

View File

@ -113,6 +113,12 @@ jobs:
install_steps: mbedtls
configure: CC=clang LDFLAGS="-Wl,-rpath,$HOME/mbedtls/lib" --with-mbedtls=$HOME/mbedtls --enable-debug
- name: mbedtls
install_packages: libnghttp2-dev
install_steps: mbedtls
PKG_CONFIG_PATH: '$HOME/mbedtls/lib/pkgconfig' # Requires v3.6.0 or upper
generate: -DCURL_USE_MBEDTLS=ON -DENABLE_DEBUG=ON
- name: mbedtls-pkg
install_packages: libnghttp2-dev libmbedtls-dev
generate: -DCURL_USE_MBEDTLS=ON -DENABLE_DEBUG=ON -DCURL_USE_PKGCONFIG=OFF
@ -122,6 +128,12 @@ jobs:
install_steps: quictls msh3
configure: LDFLAGS="-Wl,-rpath,$HOME/msh3/lib -Wl,-rpath,$HOME/quictls/lib" --with-msh3=$HOME/msh3 --with-openssl=$HOME/quictls --enable-debug
- name: msh3
install_packages: zlib1g-dev
install_steps: quictls msh3 skipall
PKG_CONFIG_PATH: '$HOME/msh3/lib/pkgconfig' # Broken as of v0.6.0
generate: -DOPENSSL_ROOT_DIR=$HOME/quictls -DUSE_MSH3=ON -DMSH3_INCLUDE_DIR=$HOME/msh3/include -DMSH3_LIBRARY=$HOME/msh3/lib/libmsh3.so -DENABLE_DEBUG=ON
- name: awslc
install_packages: zlib1g-dev
install_steps: awslc
@ -227,6 +239,12 @@ jobs:
install_steps: rust rustls pytest
configure: --with-rustls=$HOME/rustls --enable-debug
- name: rustls
install_packages: libpsl-dev
install_steps: rust rustls skipall
PKG_CONFIG_PATH: '$HOME/rustls/lib/pkgconfig' # Not built as of v0.14.0
generate: -DCURL_USE_RUSTLS=ON -DRUSTLS_INCLUDE_DIR=$HOME/rustls/include -DRUSTLS_LIBRARY=$HOME/rustls/lib/librustls.a -DENABLE_DEBUG=ON
- name: IntelC !SSL
install_packages: zlib1g-dev
install_steps: intel
@ -570,6 +588,9 @@ jobs:
- name: 'configure'
run: |
[[ '${{ matrix.build.install_steps }}' = *'awslc'* ]] && sudo apt remove --yes libssl-dev
if [ -n '${{ matrix.build.PKG_CONFIG_PATH }}' ]; then
export PKG_CONFIG_PATH="${{ matrix.build.PKG_CONFIG_PATH }}"
fi
if [ -n '${{ matrix.build.generate }}' ]; then
cmake -B . -G Ninja \
-DCMAKE_C_COMPILER_TARGET=$(uname -m)-pc-linux-gnu -DBUILD_STATIC_LIBS=ON \

View File

@ -33,41 +33,35 @@
# MSH3_FOUND System has msh3
# MSH3_INCLUDE_DIRS The msh3 include directories
# MSH3_LIBRARIES The msh3 library names
# MSH3_LIBRARY_DIRS The msh3 library directories
# MSH3_CFLAGS Required compiler flags
# MSH3_VERSION Version of msh3
if(CURL_USE_PKGCONFIG)
if(CURL_USE_PKGCONFIG AND
NOT DEFINED MSH3_INCLUDE_DIR AND
NOT DEFINED MSH3_LIBRARY)
find_package(PkgConfig QUIET)
pkg_check_modules(PC_MSH3 "libmsh3")
pkg_check_modules(MSH3 "libmsh3")
endif()
find_path(MSH3_INCLUDE_DIR NAMES "msh3.h"
HINTS
${PC_MSH3_INCLUDEDIR}
${PC_MSH3_INCLUDE_DIRS}
)
find_library(MSH3_LIBRARY NAMES "msh3"
HINTS
${PC_MSH3_LIBDIR}
${PC_MSH3_LIBRARY_DIRS}
)
if(PC_MSH3_VERSION)
set(MSH3_VERSION ${PC_MSH3_VERSION})
endif()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(MSH3
REQUIRED_VARS
MSH3_INCLUDE_DIR
MSH3_LIBRARY
VERSION_VAR
MSH3_VERSION
)
if(MSH3_FOUND)
set(MSH3_INCLUDE_DIRS ${MSH3_INCLUDE_DIR})
set(MSH3_LIBRARIES ${MSH3_LIBRARY})
endif()
string(REPLACE ";" " " MSH3_CFLAGS "${MSH3_CFLAGS}")
message(STATUS "Found MSH3 (via pkg-config): ${MSH3_INCLUDE_DIRS} (found version \"${MSH3_VERSION}\")")
else()
find_path(MSH3_INCLUDE_DIR NAMES "msh3.h")
find_library(MSH3_LIBRARY NAMES "msh3")
mark_as_advanced(MSH3_INCLUDE_DIR MSH3_LIBRARY)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(MSH3
REQUIRED_VARS
MSH3_INCLUDE_DIR
MSH3_LIBRARY
)
if(MSH3_FOUND)
set(MSH3_INCLUDE_DIRS ${MSH3_INCLUDE_DIR})
set(MSH3_LIBRARIES ${MSH3_LIBRARY})
endif()
mark_as_advanced(MSH3_INCLUDE_DIR MSH3_LIBRARY)
endif()

View File

@ -36,6 +36,8 @@
# MBEDTLS_FOUND System has mbedtls
# MBEDTLS_INCLUDE_DIRS The mbedtls include directories
# MBEDTLS_LIBRARIES The mbedtls library names
# MBEDTLS_LIBRARY_DIRS The mbedtls library directories
# MBEDTLS_CFLAGS Required compiler flags
# MBEDTLS_VERSION Version of mbedtls
if(DEFINED MBEDTLS_INCLUDE_DIRS AND NOT DEFINED MBEDTLS_INCLUDE_DIR)
@ -44,68 +46,62 @@ if(DEFINED MBEDTLS_INCLUDE_DIRS AND NOT DEFINED MBEDTLS_INCLUDE_DIR)
unset(MBEDTLS_INCLUDE_DIRS)
endif()
if(CURL_USE_PKGCONFIG)
if(CURL_USE_PKGCONFIG AND
NOT DEFINED MBEDTLS_INCLUDE_DIR AND
NOT DEFINED MBEDTLS_LIBRARY AND
NOT DEFINED MBEDX509_LIBRARY AND
NOT DEFINED MBEDCRYPTO_LIBRARY)
find_package(PkgConfig QUIET)
pkg_check_modules(PC_MBEDTLS "mbedtls")
pkg_check_modules(MBEDTLS "mbedtls")
pkg_check_modules(MBEDX509 "mbedx509")
pkg_check_modules(MBEDCRYPTO "mbedcrypto")
endif()
find_path(MBEDTLS_INCLUDE_DIR NAMES "mbedtls/ssl.h"
HINTS
${PC_MBEDTLS_INCLUDEDIR}
${PC_MBEDTLS_INCLUDE_DIRS}
)
if(MBEDTLS_FOUND AND MBEDX509_FOUND AND MBEDCRYPTO_FOUND)
list(APPEND MBEDTLS_LIBRARIES ${MBEDX509_LIBRARIES} ${MBEDCRYPTO_LIBRARIES})
list(REMOVE_DUPLICATES MBEDTLS_LIBRARIES)
string(REPLACE ";" " " MBEDTLS_CFLAGS "${MBEDTLS_CFLAGS}")
message(STATUS "Found MbedTLS (via pkg-config): ${MBEDTLS_INCLUDE_DIRS} (found version \"${MBEDTLS_VERSION}\")")
else()
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")
find_library(MBEDTLS_LIBRARY NAMES "mbedtls"
HINTS
${PC_MBEDTLS_LIBDIR}
${PC_MBEDTLS_LIBRARY_DIRS}
)
find_library(MBEDX509_LIBRARY NAMES "mbedx509"
HINTS
${PC_MBEDTLS_LIBDIR}
${PC_MBEDTLS_LIBRARY_DIRS}
)
find_library(MBEDCRYPTO_LIBRARY NAMES "mbedcrypto"
HINTS
${PC_MBEDTLS_LIBDIR}
${PC_MBEDTLS_LIBRARY_DIRS}
)
if(PC_MBEDTLS_VERSION)
set(MBEDTLS_VERSION ${PC_MBEDTLS_VERSION})
elseif(MBEDTLS_INCLUDE_DIR)
if(EXISTS "${MBEDTLS_INCLUDE_DIR}/mbedtls/build_info.h") # 3.x
set(_version_header "${MBEDTLS_INCLUDE_DIR}/mbedtls/build_info.h")
elseif(EXISTS "${MBEDTLS_INCLUDE_DIR}/mbedtls/version.h") # 2.x
set(_version_header "${MBEDTLS_INCLUDE_DIR}/mbedtls/version.h")
else()
unset(_version_header)
if(MBEDTLS_INCLUDE_DIR)
if(EXISTS "${MBEDTLS_INCLUDE_DIR}/mbedtls/build_info.h") # 3.x
set(_version_header "${MBEDTLS_INCLUDE_DIR}/mbedtls/build_info.h")
elseif(EXISTS "${MBEDTLS_INCLUDE_DIR}/mbedtls/version.h") # 2.x
set(_version_header "${MBEDTLS_INCLUDE_DIR}/mbedtls/version.h")
else()
unset(_version_header)
endif()
if(_version_header)
set(_version_regex "#[\t ]*define[\t ]+MBEDTLS_VERSION_STRING[\t ]+\"([0-9.]+)\"")
file(STRINGS "${_version_header}" _version_str REGEX "${_version_regex}")
string(REGEX REPLACE "${_version_regex}" "\\1" _version_str "${_version_str}")
set(MBEDTLS_VERSION "${_version_str}")
unset(_version_regex)
unset(_version_str)
unset(_version_header)
endif()
endif()
if(_version_header)
set(_version_regex "#[\t ]*define[\t ]+MBEDTLS_VERSION_STRING[\t ]+\"([0-9.]+)\"")
file(STRINGS "${_version_header}" _version_str REGEX "${_version_regex}")
string(REGEX REPLACE "${_version_regex}" "\\1" _version_str "${_version_str}")
set(MBEDTLS_VERSION "${_version_str}")
unset(_version_regex)
unset(_version_str)
unset(_version_header)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(MbedTLS
REQUIRED_VARS
MBEDTLS_INCLUDE_DIR
MBEDTLS_LIBRARY
MBEDX509_LIBRARY
MBEDCRYPTO_LIBRARY
VERSION_VAR
MBEDTLS_VERSION
)
if(MBEDTLS_FOUND)
set(MBEDTLS_INCLUDE_DIRS ${MBEDTLS_INCLUDE_DIR})
set(MBEDTLS_LIBRARIES ${MBEDTLS_LIBRARY} ${MBEDX509_LIBRARY} ${MBEDCRYPTO_LIBRARY})
endif()
mark_as_advanced(MBEDTLS_INCLUDE_DIR MBEDTLS_LIBRARY MBEDX509_LIBRARY MBEDCRYPTO_LIBRARY)
endif()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(MbedTLS
REQUIRED_VARS
MBEDTLS_INCLUDE_DIR
MBEDTLS_LIBRARY
MBEDX509_LIBRARY
MBEDCRYPTO_LIBRARY
VERSION_VAR
MBEDTLS_VERSION
)
if(MBEDTLS_FOUND)
set(MBEDTLS_INCLUDE_DIRS ${MBEDTLS_INCLUDE_DIR})
set(MBEDTLS_LIBRARIES ${MBEDTLS_LIBRARY} ${MBEDX509_LIBRARY} ${MBEDCRYPTO_LIBRARY})
endif()
mark_as_advanced(MBEDTLS_INCLUDE_DIR MBEDTLS_LIBRARY MBEDX509_LIBRARY MBEDCRYPTO_LIBRARY)

View File

@ -33,41 +33,35 @@
# QUICHE_FOUND System has quiche
# QUICHE_INCLUDE_DIRS The quiche include directories
# QUICHE_LIBRARIES The quiche library names
# QUICHE_LIBRARY_DIRS The quiche library directories
# QUICHE_CFLAGS Required compiler flags
# QUICHE_VERSION Version of quiche
if(CURL_USE_PKGCONFIG)
if(CURL_USE_PKGCONFIG AND
NOT DEFINED QUICHE_INCLUDE_DIR AND
NOT DEFINED QUICHE_LIBRARY)
find_package(PkgConfig QUIET)
pkg_check_modules(PC_QUICHE "quiche")
pkg_check_modules(QUICHE "quiche")
endif()
find_path(QUICHE_INCLUDE_DIR NAMES "quiche.h"
HINTS
${PC_QUICHE_INCLUDEDIR}
${PC_QUICHE_INCLUDE_DIRS}
)
find_library(QUICHE_LIBRARY NAMES "quiche"
HINTS
${PC_QUICHE_LIBDIR}
${PC_QUICHE_LIBRARY_DIRS}
)
if(PC_QUICHE_VERSION)
set(QUICHE_VERSION ${PC_QUICHE_VERSION})
endif()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Quiche
REQUIRED_VARS
QUICHE_INCLUDE_DIR
QUICHE_LIBRARY
VERSION_VAR
QUICHE_VERSION
)
if(QUICHE_FOUND)
set(QUICHE_INCLUDE_DIRS ${QUICHE_INCLUDE_DIR})
set(QUICHE_LIBRARIES ${QUICHE_LIBRARY})
endif()
string(REPLACE ";" " " QUICHE_CFLAGS "${QUICHE_CFLAGS}")
message(STATUS "Found Quiche (via pkg-config): ${QUICHE_INCLUDE_DIRS} (found version \"${QUICHE_VERSION}\")")
else()
find_path(QUICHE_INCLUDE_DIR NAMES "quiche.h")
find_library(QUICHE_LIBRARY NAMES "quiche")
mark_as_advanced(QUICHE_INCLUDE_DIR QUICHE_LIBRARY)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Quiche
REQUIRED_VARS
QUICHE_INCLUDE_DIR
QUICHE_LIBRARY
)
if(QUICHE_FOUND)
set(QUICHE_INCLUDE_DIRS ${QUICHE_INCLUDE_DIR})
set(QUICHE_LIBRARIES ${QUICHE_LIBRARY})
endif()
mark_as_advanced(QUICHE_INCLUDE_DIR QUICHE_LIBRARY)
endif()

View File

@ -33,41 +33,64 @@
# RUSTLS_FOUND System has rustls
# RUSTLS_INCLUDE_DIRS The rustls include directories
# RUSTLS_LIBRARIES The rustls library names
# RUSTLS_LIBRARY_DIRS The rustls library directories
# RUSTLS_CFLAGS Required compiler flags
# RUSTLS_VERSION Version of rustls
if(CURL_USE_PKGCONFIG)
if(CURL_USE_PKGCONFIG AND
NOT DEFINED RUSTLS_INCLUDE_DIR AND
NOT DEFINED RUSTLS_LIBRARY)
find_package(PkgConfig QUIET)
pkg_check_modules(PC_RUSTLS "rustls")
pkg_check_modules(RUSTLS "rustls")
endif()
find_path(RUSTLS_INCLUDE_DIR NAMES "rustls.h"
HINTS
${PC_RUSTLS_INCLUDEDIR}
${PC_RUSTLS_INCLUDE_DIRS}
)
find_library(RUSTLS_LIBRARY NAMES "rustls"
HINTS
${PC_RUSTLS_LIBDIR}
${PC_RUSTLS_LIBRARY_DIRS}
)
if(PC_RUSTLS_VERSION)
set(RUSTLS_VERSION ${PC_RUSTLS_VERSION})
endif()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Rustls
REQUIRED_VARS
RUSTLS_INCLUDE_DIR
RUSTLS_LIBRARY
VERSION_VAR
RUSTLS_VERSION
)
if(RUSTLS_FOUND)
set(RUSTLS_INCLUDE_DIRS ${RUSTLS_INCLUDE_DIR})
set(RUSTLS_LIBRARIES ${RUSTLS_LIBRARY})
string(REPLACE ";" " " RUSTLS_CFLAGS "${RUSTLS_CFLAGS}")
message(STATUS "Found Rustls (via pkg-config): ${RUSTLS_INCLUDE_DIRS} (found version \"${RUSTLS_VERSION}\")")
else()
find_path(RUSTLS_INCLUDE_DIR NAMES "rustls.h")
find_library(RUSTLS_LIBRARY NAMES "rustls")
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Rustls
REQUIRED_VARS
RUSTLS_INCLUDE_DIR
RUSTLS_LIBRARY
)
if(RUSTLS_FOUND)
set(RUSTLS_INCLUDE_DIRS ${RUSTLS_INCLUDE_DIR})
set(RUSTLS_LIBRARIES ${RUSTLS_LIBRARY})
endif()
mark_as_advanced(RUSTLS_INCLUDE_DIR RUSTLS_LIBRARY)
endif()
mark_as_advanced(RUSTLS_INCLUDE_DIR RUSTLS_LIBRARY)
if(APPLE)
find_library(SECURITY_FRAMEWORK "Security")
mark_as_advanced(SECURITY_FRAMEWORK)
if(NOT SECURITY_FRAMEWORK)
message(FATAL_ERROR "Security framework not found")
endif()
list(APPEND RUSTLS_LIBRARIES "-framework Security")
find_library(FOUNDATION_FRAMEWORK "Foundation")
mark_as_advanced(FOUNDATION_FRAMEWORK)
if(NOT FOUNDATION_FRAMEWORK)
message(FATAL_ERROR "Foundation framework not found")
endif()
list(APPEND RUSTLS_LIBRARIES "-framework Foundation")
elseif(NOT WIN32)
find_library(_pthread_library "pthread")
if(_pthread_library)
list(APPEND RUSTLS_LIBRARIES "pthread")
endif()
find_library(_dl_library "dl")
if(_dl_library)
list(APPEND RUSTLS_LIBRARIES "dl")
endif()
find_library(_math_library "m")
if(_math_library)
list(APPEND RUSTLS_LIBRARIES "m")
endif()
endif()

View File

@ -35,6 +35,8 @@
# WOLFSSL_FOUND System has wolfssl
# WOLFSSL_INCLUDE_DIRS The wolfssl include directories
# WOLFSSL_LIBRARIES The wolfssl library names
# WOLFSSL_LIBRARY_DIRS The wolfssl library directories
# WOLFSSL_CFLAGS Required compiler flags
# WOLFSSL_VERSION Version of wolfssl
if(DEFINED WolfSSL_INCLUDE_DIR AND NOT DEFINED WOLFSSL_INCLUDE_DIR)
@ -46,53 +48,49 @@ if(DEFINED WolfSSL_LIBRARY AND NOT DEFINED WOLFSSL_LIBRARY)
set(WOLFSSL_LIBRARY "${WolfSSL_LIBRARY}")
endif()
if(CURL_USE_PKGCONFIG)
if(CURL_USE_PKGCONFIG AND
NOT DEFINED WOLFSSL_INCLUDE_DIR AND
NOT DEFINED WOLFSSL_LIBRARY)
find_package(PkgConfig QUIET)
pkg_check_modules(PC_WOLFSSL "wolfssl")
pkg_check_modules(WOLFSSL "wolfssl")
endif()
find_path(WOLFSSL_INCLUDE_DIR NAMES "wolfssl/ssl.h"
HINTS
${PC_WOLFSSL_INCLUDEDIR}
${PC_WOLFSSL_INCLUDE_DIRS}
)
find_library(WOLFSSL_LIBRARY NAMES "wolfssl"
HINTS
${PC_WOLFSSL_LIBDIR}
${PC_WOLFSSL_LIBRARY_DIRS}
)
if(PC_WOLFSSL_VERSION)
set(WOLFSSL_VERSION ${PC_WOLFSSL_VERSION})
elseif(WOLFSSL_INCLUDE_DIR AND EXISTS "${WOLFSSL_INCLUDE_DIR}/wolfssl/version.h")
set(_version_regex "#[\t ]*define[\t ]+LIBWOLFSSL_VERSION_STRING[\t ]+\"([^\"]*)\"")
file(STRINGS "${WOLFSSL_INCLUDE_DIR}/wolfssl/version.h" _version_str REGEX "${_version_regex}")
string(REGEX REPLACE "${_version_regex}" "\\1" _version_str "${_version_str}")
set(WOLFSSL_VERSION "${_version_str}")
unset(_version_regex)
unset(_version_str)
endif()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(WolfSSL
REQUIRED_VARS
WOLFSSL_INCLUDE_DIR
WOLFSSL_LIBRARY
VERSION_VAR
WOLFSSL_VERSION
)
if(WOLFSSL_FOUND)
set(WOLFSSL_INCLUDE_DIRS ${WOLFSSL_INCLUDE_DIR})
set(WOLFSSL_LIBRARIES ${WOLFSSL_LIBRARY})
string(REPLACE ";" " " WOLFSSL_CFLAGS "${WOLFSSL_CFLAGS}")
message(STATUS "Found WolfSSL (via pkg-config): ${WOLFSSL_INCLUDE_DIRS} (found version \"${WOLFSSL_VERSION}\")")
else()
find_path(WOLFSSL_INCLUDE_DIR NAMES "wolfssl/ssl.h")
find_library(WOLFSSL_LIBRARY NAMES "wolfssl")
if(NOT WIN32)
find_library(_math_library "m")
if(_math_library)
list(APPEND WOLFSSL_LIBRARIES "m") # for log and pow
endif()
if(WOLFSSL_INCLUDE_DIR AND EXISTS "${WOLFSSL_INCLUDE_DIR}/wolfssl/version.h")
set(_version_regex "#[\t ]*define[\t ]+LIBWOLFSSL_VERSION_STRING[\t ]+\"([^\"]*)\"")
file(STRINGS "${WOLFSSL_INCLUDE_DIR}/wolfssl/version.h" _version_str REGEX "${_version_regex}")
string(REGEX REPLACE "${_version_regex}" "\\1" _version_str "${_version_str}")
set(WOLFSSL_VERSION "${_version_str}")
unset(_version_regex)
unset(_version_str)
endif()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(WolfSSL
REQUIRED_VARS
WOLFSSL_INCLUDE_DIR
WOLFSSL_LIBRARY
VERSION_VAR
WOLFSSL_VERSION
)
if(WOLFSSL_FOUND)
set(WOLFSSL_INCLUDE_DIRS ${WOLFSSL_INCLUDE_DIR})
set(WOLFSSL_LIBRARIES ${WOLFSSL_LIBRARY})
endif()
mark_as_advanced(WOLFSSL_INCLUDE_DIR WOLFSSL_LIBRARY)
endif()
mark_as_advanced(WOLFSSL_INCLUDE_DIR WOLFSSL_LIBRARY)
if(NOT WIN32)
find_library(_math_library "m")
if(_math_library)
list(APPEND WOLFSSL_LIBRARIES "m") # for log and pow
endif()
endif()

View File

@ -74,3 +74,12 @@ macro(curl_dependency_option _dependency)
find_package(${_dependency} REQUIRED)
endif()
endmacro()
# Convert the passed paths (or list of paths) to libpath linker options
# and add them to CMAKE_REQUIRED_LINK_OPTIONS.
macro(curl_required_libpaths)
set(_libpaths "${ARGN}")
foreach(_libpath IN LISTS _libpaths)
list(APPEND CMAKE_REQUIRED_LINK_OPTIONS "${CMAKE_LIBRARY_PATH_FLAG}${_libpath}")
endforeach()
endmacro()

View File

@ -622,8 +622,13 @@ if(CURL_USE_MBEDTLS)
set(_ssl_enabled ON)
set(USE_MBEDTLS ON)
list(APPEND CURL_LIBS ${MBEDTLS_LIBRARIES})
list(APPEND CURL_LIBDIRS ${MBEDTLS_LIBRARY_DIRS})
list(APPEND LIBCURL_PC_REQUIRES_PRIVATE "mbedtls")
include_directories(SYSTEM ${MBEDTLS_INCLUDE_DIRS})
link_directories(${MBEDTLS_LIBRARY_DIRS})
if(MBEDTLS_CFLAGS)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${MBEDTLS_CFLAGS}")
endif()
if(CURL_DEFAULT_SSL_BACKEND AND CURL_DEFAULT_SSL_BACKEND STREQUAL "mbedtls")
set(_valid_default_ssl_backend TRUE)
@ -651,8 +656,13 @@ if(CURL_USE_WOLFSSL)
set(_ssl_enabled ON)
set(USE_WOLFSSL ON)
list(APPEND CURL_LIBS ${WOLFSSL_LIBRARIES})
list(APPEND CURL_LIBDIRS ${WOLFSSL_LIBRARY_DIRS})
list(APPEND LIBCURL_PC_REQUIRES_PRIVATE "wolfssl")
include_directories(SYSTEM ${WOLFSSL_INCLUDE_DIRS})
link_directories(${WOLFSSL_LIBRARY_DIRS})
if(WOLFSSL_CFLAGS)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${WOLFSSL_CFLAGS}")
endif()
if(CURL_DEFAULT_SSL_BACKEND AND CURL_DEFAULT_SSL_BACKEND STREQUAL "wolfssl")
set(_valid_default_ssl_backend TRUE)
@ -702,8 +712,13 @@ if(CURL_USE_RUSTLS)
set(_ssl_enabled ON)
set(USE_RUSTLS ON)
list(APPEND CURL_LIBS ${RUSTLS_LIBRARIES})
list(APPEND CURL_LIBDIRS ${RUSTLS_LIBRARY_DIRS})
list(APPEND LIBCURL_PC_REQUIRES_PRIVATE "rustls")
include_directories(SYSTEM ${RUSTLS_INCLUDE_DIRS})
link_directories(${RUSTLS_LIBRARY_DIRS})
if(RUSTLS_CFLAGS)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${RUSTLS_CFLAGS}")
endif()
if(CURL_DEFAULT_SSL_BACKEND AND CURL_DEFAULT_SSL_BACKEND STREQUAL "rustls")
set(_valid_default_ssl_backend TRUE)
@ -773,6 +788,7 @@ macro(openssl_check_symbol_exists _symbol _files _variable _extra_libs)
elseif(USE_WOLFSSL)
set(CMAKE_REQUIRED_INCLUDES "${WOLFSSL_INCLUDE_DIRS}")
set(CMAKE_REQUIRED_LIBRARIES "${WOLFSSL_LIBRARIES}")
curl_required_libpaths("${WOLFSSL_LIBRARY_DIRS}")
if(HAVE_LIBZ)
list(APPEND CMAKE_REQUIRED_INCLUDES "${ZLIB_INCLUDE_DIRS}") # Public wolfSSL headers require zlib headers
list(APPEND CMAKE_REQUIRED_LIBRARIES "${ZLIB_LIBRARIES}")
@ -893,9 +909,14 @@ if(USE_QUICHE)
message(FATAL_ERROR "quiche requires BoringSSL")
endif()
openssl_check_quic()
include_directories(SYSTEM ${QUICHE_INCLUDE_DIRS})
list(APPEND CURL_LIBS ${QUICHE_LIBRARIES})
list(APPEND CURL_LIBDIRS ${QUICHE_LIBRARY_DIRS})
list(APPEND LIBCURL_PC_REQUIRES_PRIVATE "quiche")
include_directories(SYSTEM ${QUICHE_INCLUDE_DIRS})
link_directories(${QUICHE_LIBRARY_DIRS})
if(QUICHE_CFLAGS)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${QUICHE_CFLAGS}")
endif()
if(NOT DEFINED HAVE_QUICHE_CONN_SET_QLOG_FD)
cmake_push_check_state()
set(CMAKE_REQUIRED_INCLUDES "${QUICHE_INCLUDE_DIRS}")
@ -917,9 +938,14 @@ if(USE_MSH3)
openssl_check_quic()
endif()
find_package(MSH3 REQUIRED)
include_directories(SYSTEM ${MSH3_INCLUDE_DIRS})
list(APPEND CURL_LIBS ${MSH3_LIBRARIES})
list(APPEND CURL_LIBDIRS ${MSH3_LIBRARY_DIRS})
list(APPEND LIBCURL_PC_REQUIRES_PRIVATE "libmsh3")
include_directories(SYSTEM ${MSH3_INCLUDE_DIRS})
link_directories(${MSH3_LIBRARY_DIRS})
if(MSH3_CFLAGS)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${MSH3_CFLAGS}")
endif()
endif()
if(USE_OPENSSL_QUIC)