Skip to content

Commit

Permalink
Add rclcpp_components::component (#1855)
Browse files Browse the repository at this point in the history
Signed-off-by: Shane Loretz <sloretz@osrfoundation.org>
  • Loading branch information
sloretz committed Jan 6, 2022
1 parent 2d6e636 commit 9583ec7
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions rclcpp_components/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,15 @@ find_package(composition_interfaces REQUIRED)
find_package(rclcpp REQUIRED)
find_package(rcpputils REQUIRED)

# Add an interface library that can be dependend upon by libraries who register components
add_library(component INTERFACE)
target_include_directories(component INTERFACE
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
"$<INSTALL_INTERFACE:include>")
target_link_libraries(component INTERFACE
class_loader::class_loader
rclcpp::rclcpp)

add_library(
component_manager
SHARED
Expand Down Expand Up @@ -87,10 +96,7 @@ if(BUILD_TESTING)

set(components "")
add_library(test_component SHARED test/components/test_component.cpp)
target_include_directories(test_component PUBLIC include)
ament_target_dependencies(test_component
"class_loader"
"rclcpp")
target_link_libraries(test_component PRIVATE component)
#rclcpp_components_register_nodes(test_component "test_rclcpp_components::TestComponent")
set(components "${components}test_rclcpp_components::TestComponentFoo;$<TARGET_FILE:test_component>\n")
set(components "${components}test_rclcpp_components::TestComponentBar;$<TARGET_FILE:test_component>\n")
Expand Down Expand Up @@ -138,7 +144,7 @@ if(BUILD_TESTING)
endif()

install(
TARGETS component_manager EXPORT component_manager
TARGETS component component_manager EXPORT export_${PROJECT_NAME}
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
RUNTIME DESTINATION bin
Expand All @@ -165,7 +171,7 @@ install(
# specific order: dependents before dependencies
ament_export_include_directories(include)
ament_export_libraries(component_manager)
ament_export_targets(component_manager)
ament_export_targets(export_${PROJECT_NAME})
ament_export_dependencies(ament_index_cpp)
ament_export_dependencies(class_loader)
ament_export_dependencies(composition_interfaces)
Expand Down

0 comments on commit 9583ec7

Please sign in to comment.