From c5bfa0d4cc753af62276edbb3f5c79dcae744c8d Mon Sep 17 00:00:00 2001 From: Nicolas Mora Date: Fri, 27 May 2022 10:42:33 -0400 Subject: [PATCH] Fix pkg-config file with absolute path for CMAKE_INSTALL_{INCLUDE,LIB}DIR and CMAKE_MODULE_PATH who was used as single value --- CMakeLists.txt | 12 ++++++++++++ libhoel.pc.in | 4 ++-- src/Makefile | 4 ++-- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9369c13..f0cbef5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -332,6 +332,18 @@ endif () option(INSTALL_HEADER "Install the header files" ON) # Install hoel.h or not +if(IS_ABSOLUTE "${CMAKE_INSTALL_INCLUDEDIR}") + set(PKGCONFIG_TARGET_INCLUDES "${CMAKE_INSTALL_INCLUDEDIR}") +else() + set(PKGCONFIG_TARGET_INCLUDES "\${prefix}/${CMAKE_INSTALL_INCLUDEDIR}") +endif() + +if(IS_ABSOLUTE "${CMAKE_INSTALL_LIBDIR}") + set(PKGCONFIG_TARGET_LIBDIR "${CMAKE_INSTALL_LIBDIR}") +else() + set(PKGCONFIG_TARGET_LIBDIR "\${prefix}/${CMAKE_INSTALL_LIBDIR}") +endif() + configure_file(libhoel.pc.in libhoel.pc @ONLY) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libhoel.pc diff --git a/libhoel.pc.in b/libhoel.pc.in index 116cbf5..2289437 100644 --- a/libhoel.pc.in +++ b/libhoel.pc.in @@ -1,7 +1,7 @@ prefix=@CMAKE_INSTALL_PREFIX@ exec_prefix=@CMAKE_INSTALL_PREFIX@ -libdir=${exec_prefix}/@CMAKE_INSTALL_LIBDIR@ -includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@ +libdir=@PKGCONFIG_TARGET_LIBDIR@ +includedir=@PKGCONFIG_TARGET_INCLUDES@ Name: @PROJECT_NAME@ Description: @PROJECT_DESCRIPTION@ diff --git a/src/Makefile b/src/Makefile index 703f928..b229288 100644 --- a/src/Makefile +++ b/src/Makefile @@ -98,8 +98,8 @@ $(PKGCONFIG_FILE): @cp $(PKGCONFIG_TEMPLATE) $(PKGCONFIG_FILE) @echo Pkgconfig file $(PKGCONFIG_FILE) generated @sed -i -e 's#@CMAKE_INSTALL_PREFIX@#$(DESTDIR)#g' $(PKGCONFIG_FILE) - @sed -i -e 's/@CMAKE_INSTALL_LIBDIR@/lib/g' $(PKGCONFIG_FILE) - @sed -i -e 's/@CMAKE_INSTALL_INCLUDEDIR@/include/g' $(PKGCONFIG_FILE) + @sed -i -e 's#@PKGCONFIG_TARGET_LIBDIR@#$${prefix}/lib#g' $(PKGCONFIG_FILE) + @sed -i -e 's#@PKGCONFIG_TARGET_INCLUDES@#$${prefix}/include#g' $(PKGCONFIG_FILE) @sed -i -e 's/@PROJECT_NAME@/$(PROJECT_NAME)/g' $(PKGCONFIG_FILE) @sed -i -e 's/@PROJECT_DESCRIPTION@/$(PROJECT_DESCRIPTION)/g' $(PKGCONFIG_FILE) @sed -i -e 's|@PROJECT_BUGREPORT_PATH@|$(PROJECT_BUGREPORT_PATH)|g' $(PKGCONFIG_FILE)