From 50042e2ee26ed031063ccca12e5046e2f84d2ce2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Milo=C5=A1=20Komar=C4=8Devi=C4=87?= Date: Wed, 25 Jan 2023 15:47:31 +0100 Subject: [PATCH] Handle relative and absolute paths for pkg-config file --- CMakeLists.txt | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 625e78b4..9070afe2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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)