mirror of
https://github.com/libgit2/libgit2.git
synced 2026-06-21 22:16:24 +00:00
camke: include libssh2 in Requires.private in the PC file
We need this in order for `pkg-config` to be able to tell what you should link
against when building libgit2 statically. We do include libssh2 in
`Libs.private` but not in `Requires.private`. The difference is a bit subtle but
has become important.
You can call `pkg-config --libs --static ${build}/libgit2.pc` and it will give
you what is in the Libs line, and also what the packages from the Requires field
have in theirs. This is what e.g. `rugged` does and it has been working until
recently. An update to openssl to require zstd now means that using `--libs
--static` returns `-lzstd` as well as many others. This means that those who
want to link using that command now need to have the development packages for
zstd installed, which should not be necessary as libgit2 itself doesn't want to
use anything from it.
A better command to use here seems to be `pkg-config --libs --static --pure
${build}/libgit2.pc`. The manpage and help output are not very precise but what
this does is limit the list of dependencies to a single layer, which is what we
want as we would only want to link statically against libgit2 and not the rest
of the libraries.
But trying to do so breaks building with libssh2 as it's included in the Libs
field rather than the Requires, so that command excludes any linking to libssh2.
Put libssh2 in the `Requires.private` field so we correctly express we need to
link to it when linking statically.
This is unfortunately an imperfect fix as now, if we did not find libssh2 via
pkg-config but rather via CMake's `find_package`, the combination of `--static
--pure` does not take `Libs.private` into account. However we only support this
as an edge case and we expect `pkg-config` to be available for the rest of our
dependencies.
This commit is contained in:
@@ -6,7 +6,9 @@ if(USE_SSH STREQUAL "exec")
|
||||
elseif(USE_SSH STREQUAL ON OR USE_SSH STREQUAL "libssh2")
|
||||
find_pkglibraries(LIBSSH2 libssh2)
|
||||
|
||||
if(NOT LIBSSH2_FOUND)
|
||||
if(LIBSSH2_FOUND)
|
||||
set(LIBSSH2_FOUND_PKGCONFIG 1)
|
||||
else()
|
||||
find_package(LibSSH2)
|
||||
set(LIBSSH2_INCLUDE_DIRS ${LIBSSH2_INCLUDE_DIR})
|
||||
get_filename_component(LIBSSH2_LIBRARY_DIRS "${LIBSSH2_LIBRARY}" DIRECTORY)
|
||||
@@ -20,7 +22,11 @@ elseif(USE_SSH STREQUAL ON OR USE_SSH STREQUAL "libssh2")
|
||||
|
||||
list(APPEND LIBGIT2_SYSTEM_INCLUDES ${LIBSSH2_INCLUDE_DIRS})
|
||||
list(APPEND LIBGIT2_SYSTEM_LIBS ${LIBSSH2_LIBRARIES})
|
||||
list(APPEND LIBGIT2_PC_LIBS ${LIBSSH2_LDFLAGS})
|
||||
if(LIBSSH2_FOUND_PKGCONFIG)
|
||||
list(APPEND LIBGIT2_PC_REQUIRES "libssh2")
|
||||
else()
|
||||
list(APPEND LIBGIT2_PC_LIBS ${LIBSSH2_LDFLAGS})
|
||||
endif()
|
||||
|
||||
check_library_exists("${LIBSSH2_LIBRARIES}" libssh2_userauth_publickey_frommemory "${LIBSSH2_LIBRARY_DIRS}" HAVE_LIBSSH2_MEMORY_CREDENTIALS)
|
||||
if(HAVE_LIBSSH2_MEMORY_CREDENTIALS)
|
||||
|
||||
Reference in New Issue
Block a user