FindWolfSSL.cmake 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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_package(PkgConfig QUIET)
  25. pkg_check_modules(PC_WOLFSSL QUIET "wolfssl")
  26. find_path(WolfSSL_INCLUDE_DIR
  27. NAMES "wolfssl/ssl.h"
  28. HINTS ${PC_WOLFSSL_INCLUDE_DIRS}
  29. )
  30. find_library(WolfSSL_LIBRARY
  31. NAMES "wolfssl"
  32. HINTS ${PC_WOLFSSL_LIBRARY_DIRS}
  33. )
  34. if(WolfSSL_INCLUDE_DIR)
  35. set(_version_regex "^#define[ \t]+LIBWOLFSSL_VERSION_STRING[ \t]+\"([^\"]+)\".*")
  36. file(STRINGS "${WolfSSL_INCLUDE_DIR}/wolfssl/version.h"
  37. WolfSSL_VERSION REGEX "${_version_regex}")
  38. string(REGEX REPLACE "${_version_regex}" "\\1"
  39. WolfSSL_VERSION "${WolfSSL_VERSION}")
  40. unset(_version_regex)
  41. endif()
  42. include(FindPackageHandleStandardArgs)
  43. find_package_handle_standard_args(WolfSSL
  44. REQUIRED_VARS
  45. WolfSSL_INCLUDE_DIR
  46. WolfSSL_LIBRARY
  47. VERSION_VAR WolfSSL_VERSION
  48. )
  49. if(WolfSSL_FOUND)
  50. set(WolfSSL_INCLUDE_DIRS ${WolfSSL_INCLUDE_DIR})
  51. set(WolfSSL_LIBRARIES ${WolfSSL_LIBRARY})
  52. endif()
  53. mark_as_advanced(WolfSSL_INCLUDE_DIR WolfSSL_LIBRARY)