]> git.proxmox.com Git - libgit2.git/blob - cmake/SelectSSH.cmake
New upstream version 1.4.3+dfsg.1
[libgit2.git] / cmake / SelectSSH.cmake
1 # Optional external dependency: libssh2
2 if(USE_SSH)
3 find_pkglibraries(LIBSSH2 libssh2)
4 if(NOT LIBSSH2_FOUND)
5 find_package(LibSSH2)
6 set(LIBSSH2_INCLUDE_DIRS ${LIBSSH2_INCLUDE_DIR})
7 get_filename_component(LIBSSH2_LIBRARY_DIRS "${LIBSSH2_LIBRARY}" DIRECTORY)
8 set(LIBSSH2_LIBRARIES ${LIBSSH2_LIBRARY})
9 set(LIBSSH2_LDFLAGS "-lssh2")
10 endif()
11
12 if(NOT LIBSSH2_FOUND)
13 message(FATAL_ERROR "LIBSSH2 not found. Set CMAKE_PREFIX_PATH if it is installed outside of the default search path.")
14 endif()
15 endif()
16
17 if(LIBSSH2_FOUND)
18 set(GIT_SSH 1)
19 list(APPEND LIBGIT2_SYSTEM_INCLUDES ${LIBSSH2_INCLUDE_DIRS})
20 list(APPEND LIBGIT2_SYSTEM_LIBS ${LIBSSH2_LIBRARIES})
21 list(APPEND LIBGIT2_PC_LIBS ${LIBSSH2_LDFLAGS})
22
23 check_library_exists("${LIBSSH2_LIBRARIES}" libssh2_userauth_publickey_frommemory "${LIBSSH2_LIBRARY_DIRS}" HAVE_LIBSSH2_MEMORY_CREDENTIALS)
24 if(HAVE_LIBSSH2_MEMORY_CREDENTIALS)
25 set(GIT_SSH_MEMORY_CREDENTIALS 1)
26 endif()
27 else()
28 message(STATUS "LIBSSH2 not found. Set CMAKE_PREFIX_PATH if it is installed outside of the default search path.")
29 endif()
30
31 if(WIN32 AND EMBED_SSH_PATH)
32 file(GLOB SSH_SRC "${EMBED_SSH_PATH}/src/*.c")
33 list(SORT SSH_SRC)
34 list(APPEND LIBGIT2_DEPENDENCY_OBJECTS ${SSH_SRC})
35
36 list(APPEND LIBGIT2_DEPENDENCY_INCLUDES "${EMBED_SSH_PATH}/include")
37 file(WRITE "${EMBED_SSH_PATH}/src/libssh2_config.h" "#define HAVE_WINCNG\n#define LIBSSH2_WINCNG\n#include \"../win32/libssh2_config.h\"")
38 set(GIT_SSH 1)
39 endif()
40
41 add_feature_info(SSH GIT_SSH "SSH transport support")