FindLibSSH2.cmake 1.6 KB

1234567891011121314151617181920212223242526272829303132333435
  1. # - Try to find the libssh2 library
  2. # Once done this will define
  3. #
  4. # LIBSSH2_FOUND - system has the libssh2 library
  5. # LIBSSH2_INCLUDE_DIR - the libssh2 include directory
  6. # LIBSSH2_LIBRARY - the libssh2 library name
  7. if(LIBSSH2_INCLUDE_DIR AND LIBSSH2_LIBRARY)
  8. set(LibSSH2_FIND_QUIETLY TRUE)
  9. endif()
  10. find_path(LIBSSH2_INCLUDE_DIR libssh2.h
  11. )
  12. find_library(LIBSSH2_LIBRARY NAMES ssh2
  13. )
  14. if(LIBSSH2_INCLUDE_DIR)
  15. file(STRINGS "${LIBSSH2_INCLUDE_DIR}/libssh2.h" libssh2_version_str REGEX "^#define[\t ]+LIBSSH2_VERSION_NUM[\t ]+0x[0-9][0-9][0-9][0-9][0-9][0-9].*")
  16. string(REGEX REPLACE "^.*LIBSSH2_VERSION_NUM[\t ]+0x([0-9][0-9]).*$" "\\1" LIBSSH2_VERSION_MAJOR "${libssh2_version_str}")
  17. string(REGEX REPLACE "^.*LIBSSH2_VERSION_NUM[\t ]+0x[0-9][0-9]([0-9][0-9]).*$" "\\1" LIBSSH2_VERSION_MINOR "${libssh2_version_str}")
  18. string(REGEX REPLACE "^.*LIBSSH2_VERSION_NUM[\t ]+0x[0-9][0-9][0-9][0-9]([0-9][0-9]).*$" "\\1" LIBSSH2_VERSION_PATCH "${libssh2_version_str}")
  19. string(REGEX REPLACE "^0(.+)" "\\1" LIBSSH2_VERSION_MAJOR "${LIBSSH2_VERSION_MAJOR}")
  20. string(REGEX REPLACE "^0(.+)" "\\1" LIBSSH2_VERSION_MINOR "${LIBSSH2_VERSION_MINOR}")
  21. string(REGEX REPLACE "^0(.+)" "\\1" LIBSSH2_VERSION_PATCH "${LIBSSH2_VERSION_PATCH}")
  22. set(LIBSSH2_VERSION "${LIBSSH2_VERSION_MAJOR}.${LIBSSH2_VERSION_MINOR}.${LIBSSH2_VERSION_PATCH}")
  23. endif()
  24. include(FindPackageHandleStandardArgs)
  25. find_package_handle_standard_args(LibSSH2 DEFAULT_MSG LIBSSH2_INCLUDE_DIR LIBSSH2_LIBRARY )
  26. mark_as_advanced(LIBSSH2_INCLUDE_DIR LIBSSH2_LIBRARY LIBSSH2_VERSION_MAJOR LIBSSH2_VERSION_MINOR LIBSSH2_VERSION_PATCH LIBSSH2_VERSION)