Skip to content

Commit

Permalink
Add static linkages to pkg-config file
Browse files Browse the repository at this point in the history
  • Loading branch information
kmilos committed Jan 25, 2023
1 parent ae75e63 commit 0e3b09a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
2 changes: 2 additions & 0 deletions cmake/exiv2.pc.in
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,6 @@ Description: @PROJECT_DESCRIPTION@
Version: @PROJECT_VERSION@
URL: @PACKAGE_URL@
Libs: -L${libdir} -lexiv2
Libs.private: @libs_private_for_pc_file@
Cflags: -I${includedir}
Requires.private: @requires_private_for_pc_file@
19 changes: 16 additions & 3 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,9 @@ endif()
# Other library target properties
# ---------------------------------------------------------

set(libs_private_for_pc_file "")
set(requires_private_for_pc_file "")

if (${CMAKE_CXX_COMPILER_ID} STREQUAL GNU)
# Do not check format overflows on this file, to skip a false positive warning
set_source_files_properties(value.cpp PROPERTIES COMPILE_FLAGS -Wno-format-overflow)
Expand Down Expand Up @@ -189,6 +192,7 @@ target_include_directories(exiv2lib SYSTEM PRIVATE
if (EXIV2_ENABLE_XMP OR EXIV2_ENABLE_EXTERNAL_XMP)
target_include_directories(exiv2lib PRIVATE ${EXPAT_INCLUDE_DIR})
target_link_libraries(exiv2lib PRIVATE EXPAT::EXPAT)
string(APPEND requires_private_for_pc_file " expat")
endif()

if (EXIV2_ENABLE_XMP)
Expand All @@ -211,12 +215,11 @@ target_include_directories(exiv2lib_int PUBLIC
)

if (EXIV2_ENABLE_WEBREADY)

if( EXIV2_ENABLE_CURL )
target_include_directories(exiv2lib SYSTEM PRIVATE ${CURL_INCLUDE_DIR} )
target_link_libraries(exiv2lib PRIVATE ${CURL_LIBRARIES})
string(APPEND requires_private_for_pc_file " libcurl")
endif()

endif()

if (WIN32)
Expand All @@ -239,34 +242,44 @@ else()
endif()

if( EXIV2_ENABLE_PNG )
target_link_libraries( exiv2lib PRIVATE ZLIB::ZLIB)
target_link_libraries( exiv2lib PRIVATE ZLIB::ZLIB)
string(APPEND requires_private_for_pc_file " zlib")
endif()

if( EXIV2_ENABLE_BMFF AND BROTLI_FOUND )
target_link_libraries( exiv2lib PRIVATE ${Brotli_LIBRARIES})
target_include_directories(exiv2lib PRIVATE ${Brotli_INCLUDE_DIRS})
string(APPEND requires_private_for_pc_file " libbrotlicommon libbrotlidec")
endif()

if( EXIV2_ENABLE_NLS )
target_link_libraries(exiv2lib PRIVATE ${Intl_LIBRARIES})
target_include_directories(exiv2lib PRIVATE ${Intl_INCLUDE_DIRS})
target_include_directories(exiv2lib_int PRIVATE ${Intl_INCLUDE_DIRS})
if( Intl_LIBRARIES )
string(APPEND libs_private_for_pc_file " -lintl")
endif()
# Definition needed for translations
join_paths(EXV_LOCALEDIR ".." "${CMAKE_INSTALL_LOCALEDIR}")
target_compile_definitions(exiv2lib PUBLIC EXV_LOCALEDIR="${EXV_LOCALEDIR}")
endif()

if( ICONV_FOUND )
target_link_libraries( exiv2lib PRIVATE Iconv::Iconv )
string(APPEND requires_private_for_pc_file " iconv")
endif()

if( EXIV2_ENABLE_INIH )
target_link_libraries( exiv2lib_int PRIVATE inih::libinih )
target_link_libraries( exiv2lib_int PRIVATE inih::inireader )
target_link_libraries( exiv2lib PRIVATE inih::libinih )
target_link_libraries( exiv2lib PRIVATE inih::inireader )
string(APPEND requires_private_for_pc_file " inih INIReader")
endif()

set(libs_private_for_pc_file "${libs_private_for_pc_file}" PARENT_SCOPE)
set(requires_private_for_pc_file "${requires_private_for_pc_file}" PARENT_SCOPE)

write_basic_package_version_file(exiv2ConfigVersion.cmake COMPATIBILITY ExactVersion)

install(TARGETS exiv2lib EXPORT exiv2Config
Expand Down

0 comments on commit 0e3b09a

Please sign in to comment.