Skip to content

Commit

Permalink
Merge pull request #32 from ros/relocatable
Browse files Browse the repository at this point in the history
resolve path of message file and include dirs in installspace at runtime (ros/catkin#490)
  • Loading branch information
dirk-thomas committed Aug 3, 2013
2 parents 3f864dc + cb45b13 commit a5d9faa
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 14 deletions.
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ install(
cmake/pkg-genmsg.cmake.em
cmake/pkg-genmsg.context.in
cmake/pkg-msg-extras.cmake.in
cmake/pkg-msg-paths.cmake.in
cmake/pkg-msg-paths.cmake.em
cmake/pkg-msg-paths.context.in
DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}/cmake)

catkin_python_setup()
Expand Down
29 changes: 18 additions & 11 deletions cmake/genmsg-extras.cmake.em
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ macro(add_message_files)
install(FILES ${FILES_W_PATH}
DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}/${ARG_DIRECTORY})

_prepend_path("${CMAKE_INSTALL_PREFIX}/${CATKIN_PACKAGE_SHARE_DESTINATION}/${ARG_DIRECTORY}" "${ARG_FILES}" FILES_W_PATH)
_prepend_path("${ARG_DIRECTORY}" "${ARG_FILES}" FILES_W_PATH)
list(APPEND ${PROJECT_NAME}_INSTALLED_MESSAGE_FILES ${FILES_W_PATH})
endif()
endmacro()
Expand Down Expand Up @@ -196,18 +196,21 @@ macro(generate_messages)
catkin_destinations()

# generate devel space config of message include dirs for project
set(DEVELSPACE TRUE)
set(INSTALLSPACE FALSE)
set(PKG_MSG_INCLUDE_DIRS "${${PROJECT_NAME}_MSG_INCLUDE_DIRS_DEVELSPACE}")
configure_file(
${genmsg_CMAKE_DIR}/pkg-msg-paths.cmake.in
${CATKIN_DEVEL_PREFIX}/share/${PROJECT_NAME}/cmake/${PROJECT_NAME}-msg-paths.cmake
@@ONLY)
em_expand(${genmsg_CMAKE_DIR}/pkg-msg-paths.context.in
${CMAKE_CURRENT_BINARY_DIR}/catkin_generated/${PROJECT_NAME}-msg-paths-context.py
${genmsg_CMAKE_DIR}/pkg-msg-paths.cmake.em
${CATKIN_DEVEL_PREFIX}/share/${PROJECT_NAME}/cmake/${PROJECT_NAME}-msg-paths.cmake)
# generate and install config of message include dirs for project
_prepend_path(${CMAKE_INSTALL_PREFIX}/share/${PROJECT_NAME} "${${PROJECT_NAME}_MSG_INCLUDE_DIRS_INSTALLSPACE}" INCLUDE_DIRS_W_PATH UNIQUE)
set(PKG_MSG_INCLUDE_DIRS "${INCLUDE_DIRS_W_PATH}")
configure_file(
${genmsg_CMAKE_DIR}/pkg-msg-paths.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/catkin_generated/installspace/${PROJECT_NAME}-msg-paths.cmake
@@ONLY)
set(DEVELSPACE FALSE)
set(INSTALLSPACE TRUE)
set(PKG_MSG_INCLUDE_DIRS "${${PROJECT_NAME}_MSG_INCLUDE_DIRS_INSTALLSPACE}")
em_expand(${genmsg_CMAKE_DIR}/pkg-msg-paths.context.in
${CMAKE_CURRENT_BINARY_DIR}/catkin_generated/installspace/${PROJECT_NAME}-msg-paths-context.py
${genmsg_CMAKE_DIR}/pkg-msg-paths.cmake.em
${CMAKE_CURRENT_BINARY_DIR}/catkin_generated/installspace/${PROJECT_NAME}-msg-paths.cmake)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/catkin_generated/installspace/${PROJECT_NAME}-msg-paths.cmake
DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}/cmake)

Expand Down Expand Up @@ -256,6 +259,10 @@ macro(generate_messages)
include(${config})
unset(config CACHE)

# explicitly set message include dirs for current project since information from pkg-msg-paths.cmake is not yet available
if(${dep} STREQUAL ${PROJECT_NAME})
set(${dep}_MSG_INCLUDE_DIRS ${${PROJECT_NAME}_MSG_INCLUDE_DIRS_DEVELSPACE})
endif()
foreach(path ${${dep}_MSG_INCLUDE_DIRS})
list(APPEND MSG_INCLUDE_DIRS "${dep}")
list(APPEND MSG_INCLUDE_DIRS "${path}")
Expand Down
10 changes: 10 additions & 0 deletions cmake/pkg-msg-paths.cmake.em
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# generated from genmsg/cmake/pkg-msg-paths.cmake.em

@[if DEVELSPACE]@
# message include dirs in develspace
set(@(PROJECT_NAME)_MSG_INCLUDE_DIRS "@(PKG_MSG_INCLUDE_DIRS)")
@[else]@
# message include dirs in installspace
_prepend_path("${@(PROJECT_NAME)_DIR}/.." "@(PKG_MSG_INCLUDE_DIRS)" @(PROJECT_NAME)_MSG_INCLUDE_DIRS UNIQUE)
@[end if]@
set(@(PROJECT_NAME)_MSG_DEPENDENCIES @(ARG_DEPENDENCIES))
2 changes: 0 additions & 2 deletions cmake/pkg-msg-paths.cmake.in

This file was deleted.

8 changes: 8 additions & 0 deletions cmake/pkg-msg-paths.context.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# generated from genmsg/cmake/pkg-msg-paths.context.in

DEVELSPACE = '@DEVELSPACE@' == 'TRUE'
INSTALLSPACE = '@INSTALLSPACE@' == 'TRUE'

PROJECT_NAME = '@PROJECT_NAME@'
PKG_MSG_INCLUDE_DIRS = '@PKG_MSG_INCLUDE_DIRS@'
ARG_DEPENDENCIES = '@ARG_DEPENDENCIES@'

0 comments on commit a5d9faa

Please sign in to comment.