Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve pkg-config file generation #2471

Merged
merged 3 commits into from
Jan 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,17 @@ if (EXIV2_TEAM_PACKAGING)
include(cmake/packaging.cmake)
endif()

join_paths(libdir_for_pc_file "\${prefix}" "${CMAKE_INSTALL_LIBDIR}")
join_paths(includedir_for_pc_file "\${prefix}" "${CMAKE_INSTALL_INCLUDEDIR}")
# Handle both relative and absolute paths (e.g. NixOS) for a relocatable package
if(IS_ABSOLUTE "${CMAKE_INSTALL_LIBDIR}")
set(libdir_for_pc_file "${CMAKE_INSTALL_LIBDIR}")
else()
join_paths(libdir_for_pc_file "\${exec_prefix}" "${CMAKE_INSTALL_LIBDIR}")
endif()
if(IS_ABSOLUTE "${CMAKE_INSTALL_INCLUDEDIR}")
set(includedir_for_pc_file "${CMAKE_INSTALL_INCLUDEDIR}")
else()
join_paths(includedir_for_pc_file "\${prefix}" "${CMAKE_INSTALL_INCLUDEDIR}")
endif()
configure_file(cmake/exiv2.pc.in exiv2.pc @ONLY)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/exiv2.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)

Expand Down
132 changes: 0 additions & 132 deletions cmake/FindIconv.cmake

This file was deleted.

2 changes: 2 additions & 0 deletions cmake/exiv2.pc.in
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,7 @@ Name: exiv2
Description: @PROJECT_DESCRIPTION@
Version: @PROJECT_VERSION@
URL: @PACKAGE_URL@
Requires.private: @requires_private_for_pc_file@
Libs: -L${libdir} -lexiv2
Libs.private: @libs_private_for_pc_file@
Cflags: -I${includedir}
28 changes: 24 additions & 4 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -189,10 +189,12 @@ 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)
list(APPEND requires_private_list "expat")
endif()

if (EXIV2_ENABLE_XMP)
target_link_libraries(exiv2lib PRIVATE exiv2-xmp)
list(APPEND libs_private_list "exiv2-xmp")
elseif(EXIV2_ENABLE_EXTERNAL_XMP)
target_link_libraries(exiv2lib PUBLIC ${XMPSDK_LIBRARY})
target_include_directories(exiv2lib PUBLIC ${XMPSDK_INCLUDE_DIR})
Expand All @@ -211,12 +213,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})
list(APPEND requires_private_list "libcurl")
endif()

endif()

if (WIN32)
Expand All @@ -239,34 +240,53 @@ else()
endif()

if( EXIV2_ENABLE_PNG )
target_link_libraries( exiv2lib PRIVATE ZLIB::ZLIB)
target_link_libraries( exiv2lib PRIVATE ZLIB::ZLIB)
list(APPEND requires_private_list "zlib")
endif()

if( EXIV2_ENABLE_BMFF AND BROTLI_FOUND )
target_link_libraries( exiv2lib PRIVATE ${Brotli_LIBRARIES})
target_include_directories(exiv2lib PRIVATE ${Brotli_INCLUDE_DIRS})
list(APPEND requires_private_list "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 )
list(APPEND libs_private_list "intl")
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 )
if( Iconv_FOUND AND Iconv_LIBRARIES )
target_link_libraries( exiv2lib PRIVATE Iconv::Iconv )
list(APPEND libs_private_list "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 )
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")
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)

install(TARGETS exiv2lib EXPORT exiv2Config
Expand Down