Skip to content

Commit

Permalink
fix: Use PACKAGE_PREFIX_DIR to ensure relocatable CMake install for c…
Browse files Browse the repository at this point in the history
…onan

Signed-off-by: Stefan Profanter <stefan.profanter@agile-robots.com>
  • Loading branch information
Pro committed Nov 17, 2020
1 parent 6232765 commit ebc18d9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
6 changes: 4 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -263,9 +263,11 @@ else (build_errors)
set(PKG_LIBRARIES ${PROJECT_NAME_LOWER})
set(PKG_DEPENDS)

configure_file(
configure_package_config_file(
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/ignition-config.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME_LOWER}-config.cmake" @ONLY)
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME_LOWER}-config.cmake"
INSTALL_DESTINATION ${LIB_INSTALL_DIR}/cmake/${PROJECT_NAME_LOWER}
)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME_LOWER}-config.cmake
DESTINATION ${LIB_INSTALL_DIR}/cmake/${PROJECT_NAME_LOWER}
COMPONENT cmake)
Expand Down
12 changes: 7 additions & 5 deletions cmake/ignition-config.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@ if (@PKG_NAME@_CONFIG_INCLUDED)
endif()
set(@PKG_NAME@_CONFIG_INCLUDED TRUE)

list(APPEND @PKG_NAME@_BINARY_DIRS @CMAKE_INSTALL_PREFIX@/bin)
@PACKAGE_INIT@

list(APPEND @PKG_NAME@_INCLUDE_DIRS @CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_INCLUDEDIR@)
list(APPEND @PKG_NAME@_BINARY_DIRS ${PACKAGE_PREFIX_DIR}/bin)

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

list(APPEND @PKG_NAME@_CFLAGS -I@CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_INCLUDEDIR@)
list(APPEND @PKG_NAME@_LIBRARY_DIRS ${PACKAGE_PREFIX_DIR}/@CMAKE_INSTALL_LIBDIR@)

list(APPEND @PKG_NAME@_CFLAGS -I${PACKAGE_PREFIX_DIR}/@CMAKE_INSTALL_INCLUDEDIR@)

list(APPEND @PKG_NAME@_CXX_FLAGS -std=c++11)
if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
Expand All @@ -25,4 +27,4 @@ foreach(dep @PKG_DEPENDS@)
list(APPEND @PKG_NAME@_LIBRARIES ${${dep_upper}_LIBRARIES})
endforeach()

list(APPEND @PKG_NAME@_LDFLAGS -L@CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBDIR@)
list(APPEND @PKG_NAME@_LDFLAGS -L${PACKAGE_PREFIX_DIR}/@CMAKE_INSTALL_LIBDIR@)

0 comments on commit ebc18d9

Please sign in to comment.