summaryrefslogtreecommitdiffstats
path: root/cmake/modules/FindSSH.cmake
diff options
context:
space:
mode:
Diffstat (limited to 'cmake/modules/FindSSH.cmake')
-rw-r--r--cmake/modules/FindSSH.cmake47
1 files changed, 47 insertions, 0 deletions
diff --git a/cmake/modules/FindSSH.cmake b/cmake/modules/FindSSH.cmake
new file mode 100644
index 0000000..538c699
--- /dev/null
+++ b/cmake/modules/FindSSH.cmake
@@ -0,0 +1,47 @@
1#.rst:
2# FindSSH
3# -------
4# Finds the SSH library
5#
6# This will will define the following variables::
7#
8# SSH_FOUND - system has SSH
9# SSH_INCLUDE_DIRS - the SSH include directory
10# SSH_LIBRARIES - the SSH libraries
11# SSH_DEFINITIONS - the SSH definitions
12#
13# and the following imported targets::
14#
15# SSH::SSH - The SSH library
16
17if(PKG_CONFIG_FOUND)
18 pkg_check_modules(PC_SSH libssh QUIET)
19endif()
20
21find_path(SSH_INCLUDE_DIR NAMES libssh/libssh.h
22 PATHS ${PC_SSH_INCLUDEDIR})
23find_library(SSH_LIBRARY NAMES ssh
24 PATHS ${PC_SSH_LIBDIR})
25
26set(SSH_VERSION ${PC_SSH_VERSION})
27
28include(FindPackageHandleStandardArgs)
29find_package_handle_standard_args(SSH
30 REQUIRED_VARS SSH_LIBRARY SSH_INCLUDE_DIR
31 VERSION_VAR SSH_VERSION)
32
33if(SSH_FOUND)
34 set(SSH_LIBRARIES ${SSH_LIBRARY})
35 set(SSH_INCLUDE_DIRS ${SSH_INCLUDE_DIR})
36 set(SSH_DEFINITIONS -DHAVE_LIBSSH=1)
37
38 if(NOT TARGET SSH::SSH)
39 add_library(SSH::SSH UNKNOWN IMPORTED)
40 set_target_properties(SSH::SSH PROPERTIES
41 IMPORTED_LOCATION "${SSH_LIBRARY}"
42 INTERFACE_INCLUDE_DIRECTORIES "${SSH_INCLUDE_DIR}"
43 INTERFACE_COMPILE_DEFINITIONS HAVE_LIBSSH=1)
44 endif()
45endif()
46
47mark_as_advanced(SSH_INCLUDE_DIR SSH_LIBRARY)