Skip to content

Commit f1d8c51

Browse files
authored
Merge pull request #611 from kmilos/patch-1
Relative and absolute paths for a relocatable pkgconf file
2 parents b2b4664 + 08e38a4 commit f1d8c51

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

CMakeLists.txt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,17 @@ if (PUGIXML_USE_POSTFIX)
192192
endif()
193193
endif()
194194

195+
# Handle both relative and absolute paths (e.g. NixOS) for a relocatable package
196+
if(IS_ABSOLUTE "${CMAKE_INSTALL_INCLUDEDIR}")
197+
set(PUGIXML_PC_INCLUDEDIR "${CMAKE_INSTALL_INCLUDEDIR}")
198+
else()
199+
set(PUGIXML_PC_INCLUDEDIR "\${prefix}/${CMAKE_INSTALL_INCLUDEDIR}")
200+
endif()
201+
if(IS_ABSOLUTE "${CMAKE_INSTALL_LIBDIR}")
202+
set(PUGIXML_PC_LIBDIR "${CMAKE_INSTALL_LIBDIR}")
203+
else()
204+
set(PUGIXML_PC_LIBDIR "\${exec_prefix}/${CMAKE_INSTALL_LIBDIR}")
205+
endif()
195206
configure_file(scripts/pugixml.pc.in pugixml.pc @ONLY)
196207

197208
export(TARGETS ${install-targets}

scripts/pugixml.pc.in

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
prefix=@CMAKE_INSTALL_PREFIX@
22
exec_prefix=${prefix}
3-
includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@@INSTALL_SUFFIX@
4-
libdir=@CMAKE_INSTALL_FULL_LIBDIR@@INSTALL_SUFFIX@
3+
includedir=@PUGIXML_PC_INCLUDEDIR@
4+
libdir=@PUGIXML_PC_LIBDIR@
55

66
Name: pugixml
77
Description: Light-weight, simple and fast XML parser for C++ with XPath support.

0 commit comments

Comments
 (0)