Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce relocatable <package>_IMPORT_PREFIX variable #389

Open
wants to merge 2 commits into
base: rolling
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions ament_cmake_core/cmake/core/templates/nameConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,18 @@ endif()
# flag package as ament-based to distinguish it after being find_package()-ed
set(@PROJECT_NAME@_FOUND_AMENT_PACKAGE TRUE)

# Compute relocatable install prefix. This is pretty much the same code as it
# is generated by the CMakePackageConfigHelpers module.
get_filename_component(@PROJECT_NAME@_IMPORT_PREFIX "${CMAKE_CURRENT_LIST_DIR}/../../../" ABSOLUTE)
# Use original install prefix if the package was merely found via symlink alias
get_filename_component(_realCurr "${CMAKE_CURRENT_LIST_DIR}" REALPATH)
get_filename_component(_realOrig "@CMAKE_INSTALL_PREFIX@/share/@PROJECT_NAME@/cmake" REALPATH)
if(_realCurr STREQUAL _realOrig)
set(@PROJECT_NAME@_IMPORT_PREFIX "@CMAKE_INSTALL_PREFIX@")
endif()
unset(_realCurr)
unset(_realOrig)

# include all config extra files
set(_extras "@PACKAGE_CONFIG_EXTRA_FILES@")
foreach(_extra ${_extras})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ macro(ament_export_include_directories)
if(NOT IS_ABSOLUTE "${_arg}")
# prefix relative paths with CMAKE_INSTALL_PREFIX
# while avoiding to embed any absolute path
set(_arg "\${${PROJECT_NAME}_DIR}/../../../${_arg}")
set(_arg "\${${PROJECT_NAME}_IMPORT_PREFIX}/${_arg}")
list_append_unique(_AMENT_EXPORT_RELATIVE_INCLUDE_DIRECTORIES "${_arg}")
else()
if(NOT IS_DIRECTORY "${_arg}")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ if(NOT _exported_libraries STREQUAL "")
set(_lib "NOTFOUND")
find_library(
_lib NAMES "${_library}"
PATHS "${@PROJECT_NAME@_DIR}/../../../lib"
PATHS "${@PROJECT_NAME@_IMPORT_PREFIX}/lib"
NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH
)

Expand Down