1#*************************************************************************** 2# _ _ ____ _ 3# Project ___| | | | _ \| | 4# / __| | | | |_) | | 5# | (__| |_| | _ <| |___ 6# \___|\___/|_| \_\_____| 7# 8# Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al. 9# 10# This software is licensed as described in the file COPYING, which 11# you should have received as part of this distribution. The terms 12# are also available at https://curl.se/docs/copyright.html. 13# 14# You may opt to use, copy, modify, merge, publish, distribute and/or sell 15# copies of the Software, and permit persons to whom the Software is 16# furnished to do so, under the terms of the COPYING file. 17# 18# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY 19# KIND, either express or implied. 20# 21# SPDX-License-Identifier: curl 22# 23########################################################################### 24# Find the wolfSSL library 25# 26# Input variables: 27# 28# - `WOLFSSL_INCLUDE_DIR`: The wolfSSL include directory. 29# - `WOLFSSL_LIBRARY`: Path to `wolfssl` library. 30# 31# Result variables: 32# 33# - `WOLFSSL_FOUND`: System has wolfSSL. 34# - `WOLFSSL_INCLUDE_DIRS`: The wolfSSL include directories. 35# - `WOLFSSL_LIBRARIES`: The wolfSSL library names. 36# - `WOLFSSL_LIBRARY_DIRS`: The wolfSSL library directories. 37# - `WOLFSSL_CFLAGS`: Required compiler flags. 38# - `WOLFSSL_VERSION`: Version of wolfSSL. 39 40if(DEFINED WolfSSL_INCLUDE_DIR AND NOT DEFINED WOLFSSL_INCLUDE_DIR) 41 message(WARNING "WolfSSL_INCLUDE_DIR is deprecated, use WOLFSSL_INCLUDE_DIR instead.") 42 set(WOLFSSL_INCLUDE_DIR "${WolfSSL_INCLUDE_DIR}") 43endif() 44if(DEFINED WolfSSL_LIBRARY AND NOT DEFINED WOLFSSL_LIBRARY) 45 message(WARNING "WolfSSL_LIBRARY is deprecated, use WOLFSSL_LIBRARY instead.") 46 set(WOLFSSL_LIBRARY "${WolfSSL_LIBRARY}") 47endif() 48 49if(CURL_USE_PKGCONFIG AND 50 NOT DEFINED WOLFSSL_INCLUDE_DIR AND 51 NOT DEFINED WOLFSSL_LIBRARY) 52 find_package(PkgConfig QUIET) 53 pkg_check_modules(WOLFSSL "wolfssl") 54endif() 55 56if(WOLFSSL_FOUND) 57 string(REPLACE ";" " " WOLFSSL_CFLAGS "${WOLFSSL_CFLAGS}") 58 message(STATUS "Found WolfSSL (via pkg-config): ${WOLFSSL_INCLUDE_DIRS} (found version \"${WOLFSSL_VERSION}\")") 59else() 60 find_path(WOLFSSL_INCLUDE_DIR NAMES "wolfssl/ssl.h") 61 find_library(WOLFSSL_LIBRARY NAMES "wolfssl") 62 63 unset(WOLFSSL_VERSION CACHE) 64 if(WOLFSSL_INCLUDE_DIR AND EXISTS "${WOLFSSL_INCLUDE_DIR}/wolfssl/version.h") 65 set(_version_regex "#[\t ]*define[\t ]+LIBWOLFSSL_VERSION_STRING[\t ]+\"([^\"]*)\"") 66 file(STRINGS "${WOLFSSL_INCLUDE_DIR}/wolfssl/version.h" _version_str REGEX "${_version_regex}") 67 string(REGEX REPLACE "${_version_regex}" "\\1" _version_str "${_version_str}") 68 set(WOLFSSL_VERSION "${_version_str}") 69 unset(_version_regex) 70 unset(_version_str) 71 endif() 72 73 include(FindPackageHandleStandardArgs) 74 find_package_handle_standard_args(WolfSSL 75 REQUIRED_VARS 76 WOLFSSL_INCLUDE_DIR 77 WOLFSSL_LIBRARY 78 VERSION_VAR 79 WOLFSSL_VERSION 80 ) 81 82 if(WOLFSSL_FOUND) 83 set(WOLFSSL_INCLUDE_DIRS ${WOLFSSL_INCLUDE_DIR}) 84 set(WOLFSSL_LIBRARIES ${WOLFSSL_LIBRARY}) 85 endif() 86 87 mark_as_advanced(WOLFSSL_INCLUDE_DIR WOLFSSL_LIBRARY) 88endif() 89 90if(NOT WIN32) 91 find_library(_math_library "m") 92 if(_math_library) 93 list(APPEND WOLFSSL_LIBRARIES "m") # for log and pow 94 endif() 95 mark_as_advanced(_math_library) 96endif() 97