From 3ba45af59eb7d1abbb1e02b4fd53f16008c9e62e Mon Sep 17 00:00:00 2001 From: Jeongseok Lee Date: Mon, 28 Dec 2020 16:53:44 -0800 Subject: [PATCH] Make dart.pc relocatable (#1529) Co-authored-by: Stefan Profanter --- CHANGELOG.md | 1 + CMakeLists.txt | 8 +++++++- cmake/dart.pc.in | 6 +++--- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 061030c13d92f..f591a9136b560 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -83,6 +83,7 @@ * Removed gccfilter: [#1464](https://github.com/dartsim/dart/pull/1464) * Allowed to set CMAKE_INSTALL_PREFIX on Windows: [#1478](https://github.com/dartsim/dart/pull/1478) * Enforced to use OpenSceneGraph 3.7.0 or greater on macOS Catalina: [#1479](https://github.com/dartsim/dart/pull/1479) + * Made `dart.pc` relocatable: [#1529](https://github.com/dartsim/dart/pull/1529) * Documentation diff --git a/CMakeLists.txt b/CMakeLists.txt index 12a429ee5f8c4..de2e3e77d3298 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -408,11 +408,17 @@ install( # Generate the DART pkg-config set(PC_CONFIG_IN ${CMAKE_SOURCE_DIR}/cmake/dart.pc.in) set(PC_CONFIG_OUT ${CMAKE_BINARY_DIR}/cmake/dart.pc) +set(PC_CONFIG_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/pkgconfig) +file(RELATIVE_PATH + RELATIVE_PATH_TO_INSTALL_PREFIX + "${PC_CONFIG_INSTALL_DIR}" + "${CMAKE_INSTALL_PREFIX}" +) if(DART_VERBOSE) message(STATUS ${PC_CONFIG_OUT}) endif() configure_file(${PC_CONFIG_IN} ${PC_CONFIG_OUT} @ONLY) -install(FILES ${PC_CONFIG_OUT} DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) +install(FILES ${PC_CONFIG_OUT} DESTINATION ${PC_CONFIG_INSTALL_DIR}) # Install a Catkin 'package.xml' file. This is required by REP-136. install(FILES package.xml DESTINATION diff --git a/cmake/dart.pc.in b/cmake/dart.pc.in index 90f3cde37ddd8..402c496c42987 100644 --- a/cmake/dart.pc.in +++ b/cmake/dart.pc.in @@ -1,8 +1,8 @@ # This file was generated by CMake for @PROJECT_NAME@ -prefix=@CMAKE_INSTALL_PREFIX@ +prefix=${pcfiledir}/@RELATIVE_PATH_TO_INSTALL_PREFIX@ exec_prefix=${prefix} -libdir=${prefix}/lib -includedir=${prefix}/include/dart +libdir=${prefix}/@CMAKE_INSTALL_LIBDIR@ +includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@/dart Name: @PROJECT_NAME@ Description: @DART_PKG_DESC@