Skip to content

Commit

Permalink
Fix pkg-config file with absolute path for CMAKE_INSTALL_{INCLUDE,LIB…
Browse files Browse the repository at this point in the history
…}DIR and CMAKE_MODULE_PATH who was used as single value
  • Loading branch information
babelouest committed May 27, 2022
1 parent cb309e7 commit c5bfa0d
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
12 changes: 12 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions libhoel.pc.in
Original file line number Diff line number Diff line change
@@ -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@
Expand Down
4 changes: 2 additions & 2 deletions src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit c5bfa0d

Please sign in to comment.