Skip to content

Commit 0a3a220

Browse files
author
Laurent Stacul
committed
Discover libssh2 without pkg-config
1 parent f1b89a2 commit 0a3a220

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

cmake/FindLibSSH2.cmake

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# LIBSSH2_FOUND - system has the libssh2 library
2+
# LIBSSH2_INCLUDE_DIR - the libssh2 include directory
3+
# LIBSSH2_LIBRARY - the libssh2 library name
4+
5+
FIND_PATH(LIBSSH2_INCLUDE_DIR libssh2.h)
6+
7+
FIND_LIBRARY(LIBSSH2_LIBRARY NAMES ssh2 libssh2)
8+
9+
INCLUDE(FindPackageHandleStandardArgs)
10+
find_package_handle_standard_args(LibSSH2
11+
REQUIRED_VARS LIBSSH2_LIBRARY LIBSSH2_INCLUDE_DIR)
12+
13+
MARK_AS_ADVANCED(LIBSSH2_INCLUDE_DIR LIBSSH2_LIBRARY)

src/CMakeLists.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,13 @@ ENDIF()
232232
# Optional external dependency: libssh2
233233
IF (USE_SSH)
234234
FIND_PKGLIBRARIES(LIBSSH2 libssh2)
235+
IF (NOT LIBSSH2_FOUND)
236+
FIND_PACKAGE(LibSSH2)
237+
SET(LIBSSH2_INCLUDE_DIRS ${LIBSSH2_INCLUDE_DIR})
238+
GET_FILENAME_COMPONENT(LIBSSH2_LIBRARY_DIRS "${LIBSSH2_LIBRARY}" DIRECTORY)
239+
SET(LIBSSH2_LIBRARIES ${LIBSSH2_LIBRARY})
240+
SET(LIBSSH2_LDFLAGS "-lssh2")
241+
ENDIF()
235242
ENDIF()
236243
IF (LIBSSH2_FOUND)
237244
SET(GIT_SSH 1)

0 commit comments

Comments
 (0)