From fde3e38ff75bfb6b58c00372707123380534028b Mon Sep 17 00:00:00 2001 From: Pino Toscano Date: Wed, 27 Dec 2023 20:15:12 +0100 Subject: [PATCH 1/2] pkg-config: do not output static linking deps when building shared lib Commit 63f992637844b981a420b8917f6e11f8d39cb948 exports the dependencies for static linking to the pkg-config file. There are two problems with the implementation: - "Requires.private" in the pkg-config file makes the pkg-config implementation require the specified modules, even when not building statically - the exiv2 library build is done either shared or static, so there is no static library in case of a shared build Hence, output the dependencies for the static linking in the pkg-config file only when the exiv2 library build is not shared (i.e. static). --- src/CMakeLists.txt | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index eb8bfc438f..06d6400432 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -288,23 +288,25 @@ if(EXIV2_ENABLE_INIH) list(APPEND requires_private_list "INIReader") endif() -# Convert private lists to delimited strings -list(SORT libs_private_list) -string(REPLACE ";" " -l" libs_private_string "${libs_private_list}") -if(libs_private_string) - string(PREPEND libs_private_string "-l") +if(NOT BUILD_SHARED_LIBS) + # Convert private lists to delimited strings + list(SORT libs_private_list) + string(REPLACE ";" " -l" libs_private_string "${libs_private_list}") + if(libs_private_string) + string(PREPEND libs_private_string "-l") + endif() + list(SORT requires_private_list) + string(REPLACE ";" ", " requires_private_string "${requires_private_list}") + + set(libs_private_for_pc_file + "${libs_private_string}" + PARENT_SCOPE + ) + set(requires_private_for_pc_file + "${requires_private_string}" + PARENT_SCOPE + ) endif() -list(SORT requires_private_list) -string(REPLACE ";" ", " requires_private_string "${requires_private_list}") - -set(libs_private_for_pc_file - "${libs_private_string}" - PARENT_SCOPE -) -set(requires_private_for_pc_file - "${requires_private_string}" - PARENT_SCOPE -) write_basic_package_version_file(exiv2ConfigVersion.cmake COMPATIBILITY ExactVersion) From a1ff1282752de6fe45451ae24551504cd22d4ea4 Mon Sep 17 00:00:00 2001 From: Pino Toscano Date: Wed, 27 Dec 2023 20:19:06 +0100 Subject: [PATCH 2/2] cmake: do not require static deps for a shared library Commit a8c3455e5cd7ee65acc5f398581e1386f7df5108, commit 5e1cf4dad900e18e6c8e18003fa4609e693c97a6, and commit 4dfb78131cf662378bc66f236ffbd572f5207233 implement & add the libraries needed in case of static linking as dependencies for the cmake config file. There are two problems with the implementation: - being unconditionally there, they will make those modules required when building against exiv2, even when not building statically - the exiv2 library build is done either shared or static, so there is no static library in case of a shared build Hence, require the dependencies for the static linking in the cmake config file only when the exiv2 library build is not shared (i.e. static). --- cmake/exiv2Config.cmake.in | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/cmake/exiv2Config.cmake.in b/cmake/exiv2Config.cmake.in index c9e2eba9b5..8ea7f726b0 100644 --- a/cmake/exiv2Config.cmake.in +++ b/cmake/exiv2Config.cmake.in @@ -3,12 +3,14 @@ cmake_minimum_required(VERSION 3.5) include(CMakeFindDependencyMacro) -if(@EXIV2_ENABLE_PNG@) # if(EXIV2_ENABLE_PNG) - find_dependency(ZLIB REQUIRED) -endif() +if(NOT @BUILD_SHARED_LIBS@) # if(NOT BUILD_SHARED_LIBS) + if(@EXIV2_ENABLE_PNG@) # if(EXIV2_ENABLE_PNG) + find_dependency(ZLIB REQUIRED) + endif() -if(@EXIV2_ENABLE_XMP@) # if(EXIV2_ENABLE_XMP) - find_dependency(EXPAT REQUIRED) + if(@EXIV2_ENABLE_XMP@) # if(EXIV2_ENABLE_XMP) + find_dependency(EXPAT REQUIRED) + endif() endif() include("${CMAKE_CURRENT_LIST_DIR}/exiv2Export.cmake")