FindWolfSSH.cmake 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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 wolfSSH library
  25. #
  26. # Input variables:
  27. #
  28. # - `WOLFSSH_INCLUDE_DIR`: The wolfSSH include directory.
  29. # - `WOLFSSH_LIBRARY`: Path to `wolfssh` library.
  30. #
  31. # Result variables:
  32. #
  33. # - `WOLFSSH_FOUND`: System has wolfSSH.
  34. # - `WOLFSSH_INCLUDE_DIRS`: The wolfSSH include directories.
  35. # - `WOLFSSH_LIBRARIES`: The wolfSSH library names.
  36. # - `WOLFSSH_VERSION`: Version of wolfSSH.
  37. find_path(WOLFSSH_INCLUDE_DIR NAMES "wolfssh/ssh.h")
  38. find_library(WOLFSSH_LIBRARY NAMES "wolfssh" "libwolfssh")
  39. unset(WOLFSSH_VERSION CACHE)
  40. if(WOLFSSH_INCLUDE_DIR AND EXISTS "${WOLFSSH_INCLUDE_DIR}/wolfssh/version.h")
  41. set(_version_regex "#[\t ]*define[\t ]+LIBWOLFSSH_VERSION_STRING[\t ]+\"([^\"]*)\"")
  42. file(STRINGS "${WOLFSSH_INCLUDE_DIR}/wolfssh/version.h" _version_str REGEX "${_version_regex}")
  43. string(REGEX REPLACE "${_version_regex}" "\\1" _version_str "${_version_str}")
  44. set(WOLFSSH_VERSION "${_version_str}")
  45. unset(_version_regex)
  46. unset(_version_str)
  47. endif()
  48. include(FindPackageHandleStandardArgs)
  49. find_package_handle_standard_args(WolfSSH
  50. REQUIRED_VARS
  51. WOLFSSH_INCLUDE_DIR
  52. WOLFSSH_LIBRARY
  53. VERSION_VAR
  54. WOLFSSH_VERSION
  55. )
  56. if(WOLFSSH_FOUND)
  57. set(WOLFSSH_INCLUDE_DIRS ${WOLFSSH_INCLUDE_DIR})
  58. set(WOLFSSH_LIBRARIES ${WOLFSSH_LIBRARY})
  59. endif()
  60. mark_as_advanced(WOLFSSH_INCLUDE_DIR WOLFSSH_LIBRARY)