Skip to content

Commit

Permalink
Merge pull request #243 from kmilos/kmilos/fix_pkgconf_paths
Browse files Browse the repository at this point in the history
Handle both relative and absolute paths for pkgconf file
  • Loading branch information
tmaurer3 authored Oct 6, 2023
2 parents 0a342db + f8324e3 commit c51184e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
12 changes: 12 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,18 @@ install(
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)

# Handle both absolute paths (e.g. NixOS) and relative for a relocatable package
if(IS_ABSOLUTE "${CMAKE_INSTALL_INCLUDEDIR}")
set(LERC_PC_INCLUDEDIR "${CMAKE_INSTALL_INCLUDEDIR}")
else()
set(LERC_PC_INCLUDEDIR "\${prefix}/${CMAKE_INSTALL_INCLUDEDIR}")
endif()
if(IS_ABSOLUTE "${CMAKE_INSTALL_LIBDIR}")
set(LERC_PC_LIBDIR "${CMAKE_INSTALL_LIBDIR}")
else()
set(LERC_PC_LIBDIR "\${exec_prefix}/${CMAKE_INSTALL_LIBDIR}")
endif()

# Configure and install pkgconfig file
configure_file(Lerc.pc.in ${CMAKE_CURRENT_BINARY_DIR}/Lerc.pc @ONLY)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/Lerc.pc
Expand Down
4 changes: 2 additions & 2 deletions Lerc.pc.in
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
prefix=@CMAKE_INSTALL_PREFIX@
exec_prefix=${prefix}
includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@
libdir=@CMAKE_INSTALL_FULL_LIBDIR@
includedir=@LERC_PC_INCLUDEDIR@
libdir=@LERC_PC_LIBDIR@

Name: @PROJECT_NAME@
Description: @PROJECT_DESCRIPTION@
Expand Down

0 comments on commit c51184e

Please sign in to comment.