FindWolfSSH.cmake 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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. if(WOLFSSH_INCLUDE_DIR AND EXISTS "${WOLFSSH_INCLUDE_DIR}/wolfssh/version.h")
  40. set(_version_regex "#[\t ]*define[\t ]+LIBWOLFSSH_VERSION_STRING[\t ]+\"([^\"]*)\"")
  41. file(STRINGS "${WOLFSSH_INCLUDE_DIR}/wolfssh/version.h" _version_str REGEX "${_version_regex}")
  42. string(REGEX REPLACE "${_version_regex}" "\\1" _version_str "${_version_str}")
  43. set(WOLFSSH_VERSION "${_version_str}")
  44. unset(_version_regex)
  45. unset(_version_str)
  46. endif()
  47. include(FindPackageHandleStandardArgs)
  48. find_package_handle_standard_args(WolfSSH
  49. REQUIRED_VARS
  50. WOLFSSH_INCLUDE_DIR
  51. WOLFSSH_LIBRARY
  52. VERSION_VAR
  53. WOLFSSH_VERSION
  54. )
  55. if(WOLFSSH_FOUND)
  56. set(WOLFSSH_INCLUDE_DIRS ${WOLFSSH_INCLUDE_DIR})
  57. set(WOLFSSH_LIBRARIES ${WOLFSSH_LIBRARY})
  58. endif()
  59. mark_as_advanced(WOLFSSH_INCLUDE_DIR WOLFSSH_LIBRARY)