From 6464301820a9ca4a56c5f02717430bbd4150c7b2 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Sun, 23 Jul 2023 14:31:39 +0000 Subject: [PATCH] cmake: (re-)add zlib to `Libs.private` in `libssh2.pc` We mistakently added transitive zlib to `Requires.private` before, then removed it. This patch re-adds zlib, but this time to `Libs.private`, which is listing raw libs and should include transitive libs as well. Also add zlib when used as a direct dependency when zlib compression support is enabled. Follow-up to ef538069a661a43134fe7b848b1fe66b2b43bdac Closes #1131 --- CMakeLists.txt | 2 ++ src/CMakeLists.txt | 2 ++ 2 files changed, 4 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5a450bc5..75da0a53 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -334,6 +334,7 @@ if(CRYPTO_BACKEND STREQUAL "OpenSSL" OR NOT CRYPTO_BACKEND) if(ZLIB_FOUND) list(APPEND LIBRARIES ${ZLIB_LIBRARIES}) + list(APPEND LIBSSH2_PC_LIBS_PRIVATE -lz) endif() endif() endif() @@ -360,6 +361,7 @@ if(CRYPTO_BACKEND STREQUAL "wolfSSL" OR NOT CRYPTO_BACKEND) if(ZLIB_FOUND) list(APPEND CRYPTO_BACKEND_INCLUDE_DIR ${ZLIB_INCLUDE_DIR}) # Public wolfSSL headers require zlib headers list(APPEND LIBRARIES ${ZLIB_LIBRARIES}) + list(APPEND LIBSSH2_PC_LIBS_PRIVATE -lz) endif() endif() endif() diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 16431faf..17674ccb 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -58,6 +58,7 @@ if(ENABLE_ZLIB_COMPRESSION) list(APPEND libssh2_INCLUDE_DIRS ${ZLIB_INCLUDE_DIRS}) list(APPEND LIBRARIES ${ZLIB_LIBRARIES}) + list(APPEND LIBSSH2_PC_LIBS_PRIVATE -lz) list(APPEND LIBSSH2_PC_REQUIRES_PRIVATE zlib) if(ZLIB_FOUND) list(APPEND libssh2_DEFINITIONS LIBSSH2_HAVE_ZLIB) @@ -184,6 +185,7 @@ if(LIBSSH2_PC_REQUIRES_PRIVATE) string(REPLACE ";" "," LIBSSH2_PC_REQUIRES_PRIVATE "${LIBSSH2_PC_REQUIRES_PRIVATE}") endif() if(LIBSSH2_PC_LIBS_PRIVATE) + list(REMOVE_DUPLICATES LIBSSH2_PC_LIBS_PRIVATE) string(REPLACE ";" " " LIBSSH2_PC_LIBS_PRIVATE "${LIBSSH2_PC_LIBS_PRIVATE}") endif() # merge the pkg-config private fields into public ones when static-only