Skip to content

Commit

Permalink
Ensure relocatable config files (#419)
Browse files Browse the repository at this point in the history
* fix: Use PACKAGE_PREFIX_DIR to ensure relocatable CMake install for conan

Signed-off-by: Stefan Profanter <[email protected]>

* Compute relative path for pkgconfig folder.
  This accounts for arch-dependent lib folders.

Signed-off-by: Steve Peters <[email protected]>
Co-authored-by: Steve Peters <[email protected]>
Co-authored-by: Jose Luis Rivero <[email protected]>
  • Loading branch information
3 people committed Jul 27, 2022
1 parent 09f44c1 commit 3e76d92
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
8 changes: 7 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -304,10 +304,16 @@ else (build_errors)

########################################
# Make the package config file
set(PC_CONFIG_INSTALL_DIR ${LIB_INSTALL_DIR}/pkgconfig)
file(RELATIVE_PATH
PC_CONFIG_RELATIVE_PATH_TO_PREFIX
"${CMAKE_INSTALL_PREFIX}/${PC_CONFIG_INSTALL_DIR}"
"${CMAKE_INSTALL_PREFIX}"
)
configure_file(${CMAKE_SOURCE_DIR}/cmake/sdformat_pc.in
${CMAKE_CURRENT_BINARY_DIR}/cmake/${PROJECT_NAME_LOWER}.pc @ONLY)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/cmake/${PROJECT_NAME_LOWER}.pc DESTINATION
${LIB_INSTALL_DIR}/pkgconfig COMPONENT pkgconfig)
${PC_CONFIG_INSTALL_DIR} COMPONENT pkgconfig)

########################################
# Configure documentation uploader
Expand Down
8 changes: 4 additions & 4 deletions cmake/sdf_config.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ if(NOT TARGET @sdf_import_target_name@)
include("${CMAKE_CURRENT_LIST_DIR}/@sdf_target_output_filename@")
endif()

list(APPEND @PKG_NAME@_INCLUDE_DIRS "@CMAKE_INSTALL_PREFIX@/include/sdformat-@SDF_VERSION@")
list(APPEND @PKG_NAME@_INCLUDE_DIRS "${PACKAGE_PREFIX_DIR}/include/sdformat-@SDF_VERSION@")

list(APPEND @PKG_NAME@_CFLAGS "-I@CMAKE_INSTALL_PREFIX@/include/sdformat-@SDF_VERSION@")
list(APPEND @PKG_NAME@_CFLAGS "-I${PACKAGE_PREFIX_DIR}/include/sdformat-@SDF_VERSION@")
if (NOT WIN32)
list(APPEND @PKG_NAME@_CXX_FLAGS "${@PKG_NAME@_CFLAGS} -std=c++17")
endif()

list(APPEND @PKG_NAME@_LIBRARY_DIRS "@CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBDIR@")
list(APPEND @PKG_NAME@_LIBRARY_DIRS "${PACKAGE_PREFIX_DIR}/@CMAKE_INSTALL_LIBDIR@")

set(@PKG_NAME@_LIBRARIES @sdf_import_target_name@)

Expand All @@ -37,4 +37,4 @@ find_package(ignition-math@IGN_MATH_VER@)
list(APPEND @PKG_NAME@_INCLUDE_DIRS ${IGNITION-MATH_INCLUDE_DIRS})
list(APPEND @PKG_NAME@_LIBRARY_DIRS ${IGNITION-MATH_LIBRARY_DIRS})

list(APPEND @PKG_NAME@_LDFLAGS "-L@CMAKE_INSTALL_PREFIX@/@LIB_INSTALL_DIR@")
list(APPEND @PKG_NAME@_LDFLAGS "-L${PACKAGE_PREFIX_DIR}/@LIB_INSTALL_DIR@")
2 changes: 1 addition & 1 deletion cmake/sdformat_pc.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
prefix="@CMAKE_INSTALL_PREFIX@"
prefix=${pcfiledir}/@PC_CONFIG_RELATIVE_PATH_TO_PREFIX@
libdir=${prefix}/@LIB_INSTALL_DIR@
includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@

Expand Down

0 comments on commit 3e76d92

Please sign in to comment.