Discover libssh2 without pkg-config

This commit is contained in:
Laurent Stacul
2021-09-14 09:53:24 +00:00
parent f1b89a201e
commit 0a3a220fa9
2 changed files with 20 additions and 0 deletions

13
cmake/FindLibSSH2.cmake Normal file
View File

@@ -0,0 +1,13 @@
# LIBSSH2_FOUND - system has the libssh2 library
# LIBSSH2_INCLUDE_DIR - the libssh2 include directory
# LIBSSH2_LIBRARY - the libssh2 library name
FIND_PATH(LIBSSH2_INCLUDE_DIR libssh2.h)
FIND_LIBRARY(LIBSSH2_LIBRARY NAMES ssh2 libssh2)
INCLUDE(FindPackageHandleStandardArgs)
find_package_handle_standard_args(LibSSH2
REQUIRED_VARS LIBSSH2_LIBRARY LIBSSH2_INCLUDE_DIR)
MARK_AS_ADVANCED(LIBSSH2_INCLUDE_DIR LIBSSH2_LIBRARY)

View File

@@ -232,6 +232,13 @@ ENDIF()
# Optional external dependency: libssh2
IF (USE_SSH)
FIND_PKGLIBRARIES(LIBSSH2 libssh2)
IF (NOT LIBSSH2_FOUND)
FIND_PACKAGE(LibSSH2)
SET(LIBSSH2_INCLUDE_DIRS ${LIBSSH2_INCLUDE_DIR})
GET_FILENAME_COMPONENT(LIBSSH2_LIBRARY_DIRS "${LIBSSH2_LIBRARY}" DIRECTORY)
SET(LIBSSH2_LIBRARIES ${LIBSSH2_LIBRARY})
SET(LIBSSH2_LDFLAGS "-lssh2")
ENDIF()
ENDIF()
IF (LIBSSH2_FOUND)
SET(GIT_SSH 1)