diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index b03b96af93a..96f648b212c 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -292,7 +292,18 @@ IF (LIBSSH2_FOUND) LIST(APPEND LIBGIT2_PC_LIBS ${LIBSSH2_LDFLAGS}) #SET(LIBGIT2_PC_LIBS "${LIBGIT2_PC_LIBS} ${LIBSSH2_LDFLAGS}") - CHECK_LIBRARY_EXISTS("${LIBSSH2_LIBRARIES}" libssh2_userauth_publickey_frommemory "${LIBSSH2_LIBRARY_DIRS}" HAVE_LIBSSH2_MEMORY_CREDENTIALS) + # We might need to provide additional libraries so libssh2 links + SET(CMAKE_REQUIRED_LIBRARIES_OLD ${CMAKE_REQUIRED_LIBRARIES}) + IF(BUILD_SHARED_LIBS) + SET(CMAKE_REQUIRED_LIBRARIES ${LIBSSH2_LIBRARIES}) + SET(LIBSSH2_TMP_LIBRARY_DIRS ${LIBSSH2_LIBRARY_DIRS}) + ELSE() + SET(CMAKE_REQUIRED_LIBRARIES ${LIBSSH2_STATIC_LIBRARIES}) + SET(LIBSSH2_TMP_LIBRARY_DIRS ${LIBSSH2_STATIC_LIBRARY_DIRS}) + ENDIF() + CHECK_LIBRARY_EXISTS(ssh2 libssh2_userauth_publickey_frommemory "${LIBSSH2_TMP_LIBRARY_DIRS}" HAVE_LIBSSH2_MEMORY_CREDENTIALS) + SET(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES_OLD}) + UNSET(LIBSSH2_TMP_LIBRARY_DIRS) IF (HAVE_LIBSSH2_MEMORY_CREDENTIALS) SET(GIT_SSH_MEMORY_CREDENTIALS 1) ENDIF()