From 8cdf8dec703d882b46ca50a769fabb95ffc48e2c Mon Sep 17 00:00:00 2001 From: manuel Date: Thu, 24 Nov 2016 21:27:41 +0100 Subject: sync with upstream --- project/cmake/modules/FindSSH.cmake | 52 +++++++++++++++++++++++++++---------- 1 file changed, 39 insertions(+), 13 deletions(-) (limited to 'project/cmake/modules/FindSSH.cmake') diff --git a/project/cmake/modules/FindSSH.cmake b/project/cmake/modules/FindSSH.cmake index 60c3537..538c699 100644 --- a/project/cmake/modules/FindSSH.cmake +++ b/project/cmake/modules/FindSSH.cmake @@ -1,21 +1,47 @@ -# - Try to find libssh -# Once done this will define +#.rst: +# FindSSH +# ------- +# Finds the SSH library # -# SSH_FOUND - system has libssh -# SSH_INCLUDE_DIRS - the libssh include directory -# SSH_LIBRARIES - The libssh libraries +# This will will define the following variables:: +# +# SSH_FOUND - system has SSH +# SSH_INCLUDE_DIRS - the SSH include directory +# SSH_LIBRARIES - the SSH libraries +# SSH_DEFINITIONS - the SSH definitions +# +# and the following imported targets:: +# +# SSH::SSH - The SSH library if(PKG_CONFIG_FOUND) - pkg_check_modules (SSH libssh) - list(APPEND SSH_INCLUDE_DIRS /usr/include) -else() - find_path(SSH_INCLUDE_DIRS libssh/libssh.h) - find_library(SSH_LIBRARIES ssh) + pkg_check_modules(PC_SSH libssh QUIET) endif() +find_path(SSH_INCLUDE_DIR NAMES libssh/libssh.h + PATHS ${PC_SSH_INCLUDEDIR}) +find_library(SSH_LIBRARY NAMES ssh + PATHS ${PC_SSH_LIBDIR}) + +set(SSH_VERSION ${PC_SSH_VERSION}) + include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(SSH DEFAULT_MSG SSH_INCLUDE_DIRS SSH_LIBRARIES) +find_package_handle_standard_args(SSH + REQUIRED_VARS SSH_LIBRARY SSH_INCLUDE_DIR + VERSION_VAR SSH_VERSION) + +if(SSH_FOUND) + set(SSH_LIBRARIES ${SSH_LIBRARY}) + set(SSH_INCLUDE_DIRS ${SSH_INCLUDE_DIR}) + set(SSH_DEFINITIONS -DHAVE_LIBSSH=1) -list(APPEND SSH_DEFINITIONS -DHAVE_LIBSSH=1) + if(NOT TARGET SSH::SSH) + add_library(SSH::SSH UNKNOWN IMPORTED) + set_target_properties(SSH::SSH PROPERTIES + IMPORTED_LOCATION "${SSH_LIBRARY}" + INTERFACE_INCLUDE_DIRECTORIES "${SSH_INCLUDE_DIR}" + INTERFACE_COMPILE_DEFINITIONS HAVE_LIBSSH=1) + endif() +endif() -mark_as_advanced(SSH_INCLUDE_DIRS SSH_LIBRARIES SSH_DEFINITIONS) +mark_as_advanced(SSH_INCLUDE_DIR SSH_LIBRARY) -- cgit v1.2.3