Warning, /network/kio-extras/cmake/Findlibssh.cmake is written in an unsupported language. File is not indexed.
0001 # - Try to find libssh 0002 # Once done this will define 0003 # 0004 # LIBSSH_FOUND - system has libssh 0005 # LIBSSH_INCLUDE_DIR - the libssh include directory 0006 # LIBSSH_LIBRARIES - Link these to use libssh 0007 # LIBSSH_DEFINITIONS - Compiler switches required for using libssh 0008 0009 # SPDX-License-Identifier: BSD-3-Clause 0010 # SPDX-FileCopyrightText: 2009-2014 Andreas Schneider <asn@cryptomilk.org> 0011 # SPDX-FileCopyrightText: 2018 Harald Sitter <sitter@kde.org> 0012 0013 # Define an imported target to have compatibility with newer libssh and so 0014 # we have a single target to use regardless of the code path taken in the 0015 # finder and the actual libssh version defining the target. 0016 macro(libssh_ensure_imported_target) 0017 if(NOT TARGET ssh) 0018 add_library(ssh SHARED IMPORTED) 0019 set_target_properties(ssh PROPERTIES 0020 IMPORTED_LOCATION "${LIBSSH_LIBRARIES}" 0021 INTERFACE_INCLUDE_DIRECTORIES "${LIBSSH_INCLUDE_DIR}" 0022 ) 0023 endif() 0024 endmacro() 0025 0026 # We prefer the config, but on Ubuntu 18.04 LTS (and to some extent later 0027 # versions it seems) they've not packaged the config properly. So, go for the 0028 # config by default and fall back to manual lookup iff the config was not found. 0029 # https://bugs.kde.org/show_bug.cgi?id=400291 0030 # https://bugs.launchpad.net/ubuntu/+source/libssh/+bug/1800135 0031 find_package(libssh ${libssh_FIND_VERSION} NO_MODULE QUIET) 0032 if(libssh_FOUND) 0033 # Certain versions with config may not have the target, so make sure it's 0034 # defined. 0035 libssh_ensure_imported_target() 0036 return() 0037 endif() 0038 0039 find_path(LIBSSH_INCLUDE_DIR 0040 NAMES 0041 libssh/libssh.h 0042 PATHS 0043 /usr/include 0044 /usr/local/include 0045 /opt/local/include 0046 /sw/include 0047 ${CMAKE_INCLUDE_PATH} 0048 ${CMAKE_INSTALL_PREFIX}/include 0049 ) 0050 0051 find_library(SSH_LIBRARY 0052 NAMES 0053 ssh 0054 libssh 0055 PATHS 0056 /usr/lib 0057 /usr/local/lib 0058 /opt/local/lib 0059 /sw/lib 0060 ${CMAKE_LIBRARY_PATH} 0061 ${CMAKE_INSTALL_PREFIX}/lib 0062 ) 0063 0064 set(LIBSSH_LIBRARIES 0065 ${LIBSSH_LIBRARIES} 0066 ${SSH_LIBRARY} 0067 ) 0068 0069 message("LIB: ${LIBSSH_LIBRARIES}; INC: ${LIBSSH_INCLUDE_DIR};") 0070 0071 if (LIBSSH_INCLUDE_DIR AND libssh_FIND_VERSION) 0072 file(STRINGS ${LIBSSH_INCLUDE_DIR}/libssh/libssh.h LIBSSH_VERSION_MAJOR 0073 REGEX "#define[ ]+LIBSSH_VERSION_MAJOR[ ]+[0-9]+") 0074 0075 # Older versions of libssh like libssh-0.2 have LIBSSH_VERSION but not LIBSSH_VERSION_MAJOR 0076 if (LIBSSH_VERSION_MAJOR) 0077 string(REGEX MATCH "[0-9]+" LIBSSH_VERSION_MAJOR ${LIBSSH_VERSION_MAJOR}) 0078 file(STRINGS ${LIBSSH_INCLUDE_DIR}/libssh/libssh.h LIBSSH_VERSION_MINOR 0079 REGEX "#define[ ]+LIBSSH_VERSION_MINOR[ ]+[0-9]+") 0080 string(REGEX MATCH "[0-9]+" LIBSSH_VERSION_MINOR ${LIBSSH_VERSION_MINOR}) 0081 file(STRINGS ${LIBSSH_INCLUDE_DIR}/libssh/libssh.h LIBSSH_VERSION_PATCH 0082 REGEX "#define[ ]+LIBSSH_VERSION_MICRO[ ]+[0-9]+") 0083 string(REGEX MATCH "[0-9]+" LIBSSH_VERSION_PATCH ${LIBSSH_VERSION_PATCH}) 0084 0085 set(LIBSSH_VERSION ${LIBSSH_VERSION_MAJOR}.${LIBSSH_VERSION_MINOR}.${LIBSSH_VERSION_PATCH}) 0086 0087 else (LIBSSH_VERSION_MAJOR) 0088 message(STATUS "LIBSSH_VERSION_MAJOR not found in ${LIBSSH_INCLUDE_DIR}/libssh/libssh.h, assuming libssh is too old") 0089 set(LIBSSH_FOUND FALSE) 0090 endif (LIBSSH_VERSION_MAJOR) 0091 endif (LIBSSH_INCLUDE_DIR AND libssh_FIND_VERSION) 0092 0093 # If the version is too old, but libs and includes are set, 0094 # find_package_handle_standard_args will set LIBSSH_FOUND to TRUE again, 0095 # so we need this if() here. 0096 include(FindPackageHandleStandardArgs) 0097 find_package_handle_standard_args(libssh 0098 FOUND_VAR 0099 LIBSSH_FOUND 0100 REQUIRED_VARS 0101 LIBSSH_LIBRARIES 0102 LIBSSH_INCLUDE_DIR 0103 VERSION_VAR 0104 LIBSSH_VERSION) 0105 0106 libssh_ensure_imported_target() 0107 0108 # show the LIBSSH_INCLUDE_DIR and LIBSSH_LIBRARIES variables only in the advanced view 0109 mark_as_advanced(LIBSSH_INCLUDE_DIR LIBSSH_LIBRARIES)