lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 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 | |
| 8 | if (LIBSSH2_INCLUDE_DIR AND LIBSSH2_LIBRARY) |
| 9 | set(LibSSH2_FIND_QUIETLY TRUE) |
| 10 | endif (LIBSSH2_INCLUDE_DIR AND LIBSSH2_LIBRARY) |
| 11 | |
| 12 | FIND_PATH(LIBSSH2_INCLUDE_DIR libssh2.h |
| 13 | ) |
| 14 | |
| 15 | FIND_LIBRARY(LIBSSH2_LIBRARY NAMES ssh2 |
| 16 | ) |
| 17 | |
| 18 | if(LIBSSH2_INCLUDE_DIR) |
| 19 | 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].*") |
| 20 | |
| 21 | string(REGEX REPLACE "^.*LIBSSH2_VERSION_NUM[\t ]+0x([0-9][0-9]).*$" "\\1" LIBSSH2_VERSION_MAJOR "${libssh2_version_str}") |
| 22 | string(REGEX REPLACE "^.*LIBSSH2_VERSION_NUM[\t ]+0x[0-9][0-9]([0-9][0-9]).*$" "\\1" LIBSSH2_VERSION_MINOR "${libssh2_version_str}") |
| 23 | 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}") |
| 24 | |
| 25 | string(REGEX REPLACE "^0(.+)" "\\1" LIBSSH2_VERSION_MAJOR "${LIBSSH2_VERSION_MAJOR}") |
| 26 | string(REGEX REPLACE "^0(.+)" "\\1" LIBSSH2_VERSION_MINOR "${LIBSSH2_VERSION_MINOR}") |
| 27 | string(REGEX REPLACE "^0(.+)" "\\1" LIBSSH2_VERSION_PATCH "${LIBSSH2_VERSION_PATCH}") |
| 28 | |
| 29 | set(LIBSSH2_VERSION "${LIBSSH2_VERSION_MAJOR}.${LIBSSH2_VERSION_MINOR}.${LIBSSH2_VERSION_PATCH}") |
| 30 | endif(LIBSSH2_INCLUDE_DIR) |
| 31 | |
| 32 | include(FindPackageHandleStandardArgs) |
| 33 | FIND_PACKAGE_HANDLE_STANDARD_ARGS(LibSSH2 DEFAULT_MSG LIBSSH2_INCLUDE_DIR LIBSSH2_LIBRARY ) |
| 34 | |
| 35 | MARK_AS_ADVANCED(LIBSSH2_INCLUDE_DIR LIBSSH2_LIBRARY LIBSSH2_VERSION_MAJOR LIBSSH2_VERSION_MINOR LIBSSH2_VERSION_PATCH LIBSSH2_VERSION) |