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

rtt_roscomm: generate dependency typekits #174

Open
wants to merge 1 commit into
base: toolchain-2.9
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
64 changes: 60 additions & 4 deletions rtt_roscomm/cmake/GenerateRTTROSCommPackage.cmake.em
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,68 @@ endmacro()

macro(ros_generate_rtt_typekit package)
cmake_parse_arguments(ros_generate_rtt_typekit "" "" "EXTRA_INCLUDES" ${ARGN})
set(_package ${package})
add_subdirectory(${rtt_roscomm_TEMPLATES_DIR}/typekit ${package}_typekit)

find_package(rtt_${package} QUIET)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This approach would prevent that the typekit is rebuilt in an existing workspace after it has been built once, for example after one message definition was updated?


if(NOT rtt_${package}_FOUND AND NOT TARGET rtt-${package}-typekit)
set(_include_dirs)
set(_pkg_libs)
set(_msg_exported_targets)
set(_typekit_targets)
set(_transport_targets)
set(_mqueue_targets)
set(_corba_targets)

include(${${package}_PREFIX}/${CATKIN_GLOBAL_SHARE_DESTINATION}/${package}/cmake/${package}-msg-paths.cmake)

foreach(dep ${${package}_MSG_DEPENDENCIES})
find_package(${dep} QUIET)

if(${dep}_FOUND)
list(APPEND _include_dirs ${${dep}_INCLUDE_DIRS})
list(APPEND _pkg_libs ${${dep}_LIBRARIES})
list(APPEND _msg_exported_targets ${${dep}_EXPORTED_TARGETS})

find_package(rtt_${dep} QUIET)

if(NOT rtt_${dep}_FOUND AND NOT TARGET rtt-${dep}-typekit)
ros_generate_rtt_typekit(${dep})
endif()

if(rtt_${dep}_FOUND)
list(APPEND _pkg_libs ${rtt_${dep}_LIBRARIES})
endif()

if(TARGET rtt-${dep}-typekit)
list(APPEND _typekit_targets rtt-${dep}-typekit)
endif()

if(TARGET rtt-${dep}-ros-transport)
list(APPEND _transport_targets rtt-${dep}-ros-transport)
endif()

if(TARGET rtt-${dep}-ros-transport-mqueue)
list(APPEND _mqueue_targets rtt-${dep}-ros-transport-mqueue)
endif()

if(TARGET rtt-${dep}-ros-transport-corba)
list(APPEND _corba_targets rtt-${dep}-ros-transport-corba)
endif()
endif()
endforeach()

set(_package ${package})
add_subdirectory(${rtt_roscomm_TEMPLATES_DIR}/typekit ${package}_typekit)
endif()
endmacro(ros_generate_rtt_typekit)

macro(ros_generate_rtt_service_proxies package)
cmake_parse_arguments(ros_generate_rtt_service_proxies "" "" "EXTRA_INCLUDES" ${ARGN})
set(_package ${package})
add_subdirectory(${rtt_roscomm_TEMPLATES_DIR}/service ${package}_service_proxies)

find_package(rtt_${package} QUIET)

if(NOT rtt_${package}_FOUND AND NOT TARGET rtt_${package}_rosservice_proxies)
set(_package ${package})
add_subdirectory(${rtt_roscomm_TEMPLATES_DIR}/service ${package}_service_proxies)
endif()
endmacro(ros_generate_rtt_service_proxies)
7 changes: 4 additions & 3 deletions rtt_roscomm/src/templates/service/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -90,16 +90,17 @@ configure_file(
include_directories(
${USE_OROCOS_INCLUDE_DIRS}
${catkin_INCLUDE_DIRS}
${${_package}_INCLUDE_DIRS})
${${_package}_INCLUDE_DIRS}
${_include_dirs})

# Targets
if(NOT DEFINED CMAKE_BUILD_TYPE OR CMAKE_BUILD_TYPE STREQUAL "Release")
set(CMAKE_BUILD_TYPE MinSizeRel)
endif()
orocos_service( rtt_${ROSPACKAGE}_rosservice_proxies ${CMAKE_CURRENT_BINARY_DIR}/rtt_rosservice_proxies.cpp)
target_link_libraries( rtt_${ROSPACKAGE}_rosservice_proxies ${catkin_LIBRARIES} ${USE_OROCOS_LIBRARIES})
target_link_libraries( rtt_${ROSPACKAGE}_rosservice_proxies ${catkin_LIBRARIES} ${_pkg_libs} ${USE_OROCOS_LIBRARIES})
if(DEFINED ${_package}_EXPORTED_TARGETS)
add_dependencies( rtt_${ROSPACKAGE}_rosservice_proxies ${${_package}_EXPORTED_TARGETS})
add_dependencies( rtt_${ROSPACKAGE}_rosservice_proxies ${${_package}_EXPORTED_TARGETS} ${_msg_exported_targets})
endif()

get_directory_property(_additional_make_clean_files ADDITIONAL_MAKE_CLEAN_FILES)
Expand Down
31 changes: 16 additions & 15 deletions rtt_roscomm/src/templates/typekit/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,8 @@ include_directories(
${rtt_roscomm_GENERATED_HEADERS_INSTALL_DESTINATION}/orocos
${USE_OROCOS_INCLUDE_DIRS}
${catkin_INCLUDE_DIRS}
${${_package}_INCLUDE_DIRS})
${${_package}_INCLUDE_DIRS}
${_include_dirs})

# Targets
if(NOT DEFINED CMAKE_BUILD_TYPE OR CMAKE_BUILD_TYPE STREQUAL "Release")
Expand All @@ -206,45 +207,45 @@ add_custom_target(rtt-${_package}-generate_boost_headers
DEPENDS ${${_package}_GENERATED_BOOST_HEADERS}
)
orocos_typekit(rtt-${_package}-typekit ${rtt-${_package}-typekit_SOURCES})
target_link_libraries(rtt-${_package}-typekit ${catkin_LIBRARIES} ${${_package}_LIBRARIES} ${USE_OROCOS_LIBRARIES})
add_dependencies(rtt-${_package}-typekit rtt-${_package}-generate_boost_headers)
target_link_libraries(rtt-${_package}-typekit ${catkin_LIBRARIES} ${${_package}_LIBRARIES} ${_pkg_libs} ${USE_OROCOS_LIBRARIES})
add_dependencies(rtt-${_package}-typekit rtt-${_package}-generate_boost_headers ${_typekit_targets})
orocos_typekit(rtt-${_package}-ros-transport ${rtt-${_package}-ros-transport_SOURCES})
target_link_libraries(rtt-${_package}-ros-transport ${catkin_LIBRARIES} ${${_package}_LIBRARIES} ${USE_OROCOS_LIBRARIES})
add_dependencies(rtt-${_package}-ros-transport rtt-${_package}-generate_boost_headers)
target_link_libraries(rtt-${_package}-ros-transport ${catkin_LIBRARIES} ${${_package}_LIBRARIES} ${_pkg_libs} ${USE_OROCOS_LIBRARIES})
add_dependencies(rtt-${_package}-ros-transport rtt-${_package}-generate_boost_headers ${_transport_targets})

# Build mqueue transport plugin
if(ENABLE_MQ)
orocos_typekit(rtt-${_package}-ros-transport-mqueue ${rtt-${_package}-ros-transport-mqueue_SOURCES})
target_link_libraries(rtt-${_package}-ros-transport-mqueue ${catkin_LIBRARIES} ${${_package}_LIBRARIES} ${USE_OROCOS_LIBRARIES} ${OROCOS-RTT_MQUEUE_LIBRARIES})
add_dependencies(rtt-${_package}-ros-transport-mqueue rtt-${_package}-generate_boost_headers)
target_link_libraries(rtt-${_package}-ros-transport-mqueue ${catkin_LIBRARIES} ${${_package}_LIBRARIES} ${_pkg_libs} ${USE_OROCOS_LIBRARIES} ${OROCOS-RTT_MQUEUE_LIBRARIES})
add_dependencies(rtt-${_package}-ros-transport-mqueue rtt-${_package}-generate_boost_headers ${_mqueue_targets})
endif()

# Build corba transport plugin
if(ENABLE_CORBA)
orocos_typekit(rtt-${_package}-ros-transport-corba ${rtt-${_package}-ros-transport-corba_SOURCES})
target_link_libraries(rtt-${_package}-ros-transport-corba ${catkin_LIBRARIES} ${${_package}_LIBRARIES} ${USE_OROCOS_LIBRARIES} ${OROCOS-RTT_CORBA_LIBRARIES})
add_dependencies(rtt-${_package}-ros-transport-corba rtt-${_package}-generate_boost_headers)
target_link_libraries(rtt-${_package}-ros-transport-corba ${catkin_LIBRARIES} ${${_package}_LIBRARIES} ${_pkg_libs} ${USE_OROCOS_LIBRARIES} ${OROCOS-RTT_CORBA_LIBRARIES})
add_dependencies(rtt-${_package}-ros-transport-corba rtt-${_package}-generate_boost_headers ${_corba_targets})
endif()

# Add an explicit dependency between the typekits and message files
# TODO: Add deps for all msg dependencies
if(${_package}_EXPORTED_TARGETS)
if(${_package}_EXPORTED_TARGETS OR DEFINED _msg_exported_targets)
if(NOT ${_package} STREQUAL ${PROJECT_NAME})
add_dependencies(rtt-${_package}-typekit ${${_package}_EXPORTED_TARGETS})
add_dependencies(rtt-${_package}-ros-transport ${${_package}_EXPORTED_TARGETS})
add_dependencies(rtt-${_package}-typekit ${${_package}_EXPORTED_TARGETS} ${_msg_exported_targets})
add_dependencies(rtt-${_package}-ros-transport ${${_package}_EXPORTED_TARGETS} ${_msg_exported_targets})
if(TARGET rtt-${_package}-ros-transport-mqueue)
add_dependencies(rtt-${_package}-ros-transport-mqueue ${${_package}_EXPORTED_TARGETS})
add_dependencies(rtt-${_package}-ros-transport-mqueue ${${_package}_EXPORTED_TARGETS} ${_msg_exported_targets})
endif()
if(TARGET rtt-${_package}-ros-transport-corba)
add_dependencies(rtt-${_package}-ros-transport-corba ${${_package}_EXPORTED_TARGETS})
add_dependencies(rtt-${_package}-ros-transport-corba ${${_package}_EXPORTED_TARGETS} ${_msg_exported_targets})
endif()
endif()
endif()

# Add the typekit libraries to the dependecies exported by this project
# LIST(APPEND ${PROJECT_NAME}_EXPORTED_TARGETS "rtt-${_package}-typekit") # <-- This is already done in orocos_typekit().
# LIST(APPEND ${PROJECT_NAME}_EXPORTED_TARGETS "rtt-${_package}-ros-transport") # <-- This is already done in orocos_typekit().
LIST(APPEND ${PROJECT_NAME}_EXPORTED_INCLUDE_DIRS "${rtt_roscomm_GENERATED_HEADERS_OUTPUT_DIRECTORY}/orocos" ${${_package}_INCLUDE_DIRS})
LIST(APPEND ${PROJECT_NAME}_EXPORTED_INCLUDE_DIRS "${rtt_roscomm_GENERATED_HEADERS_OUTPUT_DIRECTORY}/orocos" ${${_package}_INCLUDE_DIRS} ${_include_dirs})

get_directory_property(_additional_make_clean_files ADDITIONAL_MAKE_CLEAN_FILES)
list(APPEND _additional_make_clean_files "${rtt-${_package}-typekit_SOURCES};${rtt-${_package}-ros-transport_SOURCES};${rtt-${_package}-ros-transport-corba_SOURCES};${rtt-${_package}-ros-transport-mqueue_SOURCES};${rtt_roscomm_GENERATED_HEADERS_OUTPUT_DIRECTORY}/orocos/${_package}")
Expand Down