2020-03-23 21:44:29 +08:00
|
|
|
#***************************************************************************
|
|
|
|
# _ _ ____ _
|
|
|
|
# Project ___| | | | _ \| |
|
|
|
|
# / __| | | | |_) | |
|
|
|
|
# | (__| |_| | _ <| |___
|
|
|
|
# \___|\___/|_| \_\_____|
|
|
|
|
#
|
2023-01-02 20:51:48 +08:00
|
|
|
# Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
|
2020-03-23 21:44:29 +08:00
|
|
|
#
|
|
|
|
# This software is licensed as described in the file COPYING, which
|
|
|
|
# you should have received as part of this distribution. The terms
|
2020-11-04 21:02:01 +08:00
|
|
|
# are also available at https://curl.se/docs/copyright.html.
|
2020-03-23 21:44:29 +08:00
|
|
|
#
|
|
|
|
# You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
|
|
|
# copies of the Software, and permit persons to whom the Software is
|
|
|
|
# furnished to do so, under the terms of the COPYING file.
|
|
|
|
#
|
|
|
|
# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
|
|
# KIND, either express or implied.
|
|
|
|
#
|
|
|
|
# SPDX-License-Identifier: curl
|
2022-05-17 17:16:50 +08:00
|
|
|
#
|
2020-03-23 21:44:29 +08:00
|
|
|
###########################################################################
|
2024-08-05 02:35:13 +08:00
|
|
|
# Find the wolfssl library
|
|
|
|
#
|
|
|
|
# Result Variables:
|
|
|
|
#
|
|
|
|
# WolfSSL_FOUND System has wolfssl
|
|
|
|
# WolfSSL_INCLUDE_DIRS The wolfssl include directories
|
|
|
|
# WolfSSL_LIBRARIES The wolfssl library names
|
|
|
|
# WolfSSL_VERSION Version of wolfssl
|
2024-06-30 17:37:06 +08:00
|
|
|
|
2024-08-12 21:35:50 +08:00
|
|
|
if(CURL_USE_PKGCONFIG)
|
cmake: allow `pkg-config` in more envs
Before this patch, `pkg-config` was used for `UNIX` builds only (with
a few exceptions like wolfSSL, libssh, gsasl, libuv). This patch extends
`pkg-config` use to all envs except: `MSVC` without vcpkg. Meaning MSVC
with vcpkg will now use it. Also mingw on Windows.
Also apply the new condition to options where `pkg-config` was used
unconditionally (= for all targets). These are:
`-DCURL_USE_WOLFSSL=ON`, `-DCURL_USE_LIBSSH=ON`,
`-DCURL_USE_GSASL=ON` and `-DCURL_USE_LIBUV=ON`
This patch may still cause regressions for cross-builds (e.g. mingw
cross-build from Unix) and potentially other cases. If that happens, we
recommend using some of these methods to explicitly disable `pkg-config`
when using CMake:
- CMake option: `-DPKG_CONFIG_EXECUTABLE=`
(or `-DPKG_CONFIG_EXECUTABLE=nonexistent` or similar)
This is similar to the (curl-specific) `PKG_CONFIG` env for autotools.
- export env: `PKG_CONFIG_LIBDIR=`
(or `PKG_CONFIG_PATH`, `PKG_CONFIG_SYSROOT_DIR`,
or the CMake-specific `PKG_CONFIG`)
We may improve control over this in a future patch, also allowing opting
in MSVC (without vcpkg).
Ref: #14405
Ref: #14408
Ref: #14140
Closes #14483
2024-08-10 15:33:18 +08:00
|
|
|
find_package(PkgConfig QUIET)
|
|
|
|
pkg_search_module(PC_WOLFSSL QUIET "wolfssl")
|
|
|
|
endif()
|
2024-06-30 17:37:06 +08:00
|
|
|
|
2024-08-13 16:45:37 +08:00
|
|
|
find_path(WolfSSL_INCLUDE_DIR NAMES "wolfssl/ssl.h"
|
|
|
|
HINTS
|
cmake: tidy up Find modules
Smoothen out minor differences between Find modules.
- brotli, nghttp2: drop redundant `FOUND_VAR` specifiers from
`find_package_handle_standard_args()` calls.
This function sets both `<NAME_UPPER>_FOUND` and `<NAME>_FOUND`
by default.
- brotli: set result vars only when found.
- brotli: add missing `mark_as_advanced()` call.
- brotli: delete custom fail message.
- mbedtls, bearssl: use `REQUIRED_VARS` instead of `DEFAULT_MSG`.
- msh3, quiche: set `<NAME>_VERSION` (via pkg-config).
- wolfssl: also use `PC_WOLFSSL_INCLUDEDIR`, `PC_WOLFSSL_LIBDIR`
as hints.
- libpsl, libssh2, zstd: clear temporary variables used for version
detection.
- gss, msh3, nghttp2, nghttp3, ngtcp2, quiche, zstd: fix to apply
`mark_as_advanced()` to internal variables only.
Closes #14538
2024-08-14 04:31:21 +08:00
|
|
|
${PC_WOLFSSL_INCLUDEDIR}
|
2024-08-13 16:45:37 +08:00
|
|
|
${PC_WOLFSSL_INCLUDE_DIRS}
|
2024-06-30 17:37:06 +08:00
|
|
|
)
|
|
|
|
|
2024-08-13 16:45:37 +08:00
|
|
|
find_library(WolfSSL_LIBRARY NAMES "wolfssl"
|
|
|
|
HINTS
|
cmake: tidy up Find modules
Smoothen out minor differences between Find modules.
- brotli, nghttp2: drop redundant `FOUND_VAR` specifiers from
`find_package_handle_standard_args()` calls.
This function sets both `<NAME_UPPER>_FOUND` and `<NAME>_FOUND`
by default.
- brotli: set result vars only when found.
- brotli: add missing `mark_as_advanced()` call.
- brotli: delete custom fail message.
- mbedtls, bearssl: use `REQUIRED_VARS` instead of `DEFAULT_MSG`.
- msh3, quiche: set `<NAME>_VERSION` (via pkg-config).
- wolfssl: also use `PC_WOLFSSL_INCLUDEDIR`, `PC_WOLFSSL_LIBDIR`
as hints.
- libpsl, libssh2, zstd: clear temporary variables used for version
detection.
- gss, msh3, nghttp2, nghttp3, ngtcp2, quiche, zstd: fix to apply
`mark_as_advanced()` to internal variables only.
Closes #14538
2024-08-14 04:31:21 +08:00
|
|
|
${PC_WOLFSSL_LIBDIR}
|
2024-08-13 16:45:37 +08:00
|
|
|
${PC_WOLFSSL_LIBRARY_DIRS}
|
2024-06-30 17:37:06 +08:00
|
|
|
)
|
|
|
|
|
2024-08-14 04:59:50 +08:00
|
|
|
if(PC_WOLFSSL_VERSION)
|
|
|
|
set(WolfSSL_VERSION ${PC_WOLFSSL_VERSION})
|
|
|
|
elseif(WolfSSL_INCLUDE_DIR)
|
2024-06-30 17:37:06 +08:00
|
|
|
set(_version_regex "^#define[ \t]+LIBWOLFSSL_VERSION_STRING[ \t]+\"([^\"]+)\".*")
|
2024-08-13 16:45:37 +08:00
|
|
|
file(STRINGS "${WolfSSL_INCLUDE_DIR}/wolfssl/version.h" WolfSSL_VERSION REGEX "${_version_regex}")
|
|
|
|
string(REGEX REPLACE "${_version_regex}" "\\1" WolfSSL_VERSION "${WolfSSL_VERSION}")
|
2024-06-30 17:37:06 +08:00
|
|
|
unset(_version_regex)
|
|
|
|
endif()
|
2020-03-13 00:18:40 +08:00
|
|
|
|
|
|
|
include(FindPackageHandleStandardArgs)
|
|
|
|
find_package_handle_standard_args(WolfSSL
|
2024-06-30 17:37:06 +08:00
|
|
|
REQUIRED_VARS
|
|
|
|
WolfSSL_INCLUDE_DIR
|
|
|
|
WolfSSL_LIBRARY
|
2024-08-05 02:35:13 +08:00
|
|
|
VERSION_VAR
|
|
|
|
WolfSSL_VERSION
|
2024-06-30 17:37:06 +08:00
|
|
|
)
|
2020-03-13 00:18:40 +08:00
|
|
|
|
|
|
|
if(WolfSSL_FOUND)
|
|
|
|
set(WolfSSL_INCLUDE_DIRS ${WolfSSL_INCLUDE_DIR})
|
2024-06-30 17:37:06 +08:00
|
|
|
set(WolfSSL_LIBRARIES ${WolfSSL_LIBRARY})
|
2020-03-13 00:18:40 +08:00
|
|
|
endif()
|
2024-06-30 17:37:06 +08:00
|
|
|
|
|
|
|
mark_as_advanced(WolfSSL_INCLUDE_DIR WolfSSL_LIBRARY)
|