diff --git a/rclcpp/CMakeLists.txt b/rclcpp/CMakeLists.txt index c30ad4d818..ffae9cc7ee 100644 --- a/rclcpp/CMakeLists.txt +++ b/rclcpp/CMakeLists.txt @@ -16,6 +16,8 @@ find_package(rcpputils REQUIRED) find_package(rcutils REQUIRED) find_package(rmw REQUIRED) find_package(rosgraph_msgs REQUIRED) +find_package(rosidl_dynamic_typesupport REQUIRED) +find_package(rosidl_runtime_c REQUIRED) find_package(rosidl_runtime_cpp REQUIRED) find_package(rosidl_typesupport_c REQUIRED) find_package(rosidl_typesupport_cpp REQUIRED) @@ -202,23 +204,28 @@ target_include_directories(${PROJECT_NAME} PUBLIC "$" "$" "$") -target_link_libraries(${PROJECT_NAME} ${CMAKE_THREAD_LIBS_INIT}) -# specific order: dependents before dependencies -ament_target_dependencies(${PROJECT_NAME} - "ament_index_cpp" - "libstatistics_collector" - "rcl" - "rcl_interfaces" - "rcl_logging_interface" - "rcl_yaml_param_parser" - "rcpputils" - "rcutils" - "builtin_interfaces" - "rosgraph_msgs" - "rosidl_typesupport_cpp" - "rosidl_runtime_cpp" - "statistics_msgs" - "tracetools" +target_link_libraries(${PROJECT_NAME} PUBLIC + ${builtin_interfaces_TARGETS} + libstatistics_collector::libstatistics_collector + rcl::rcl + ${rcl_interfaces_TARGETS} + rcl_yaml_param_parser::rcl_yaml_param_parser + rcpputils::rcpputils + rcutils::rcutils + rmw::rmw + ${rosgraph_msgs_TARGETS} + rosidl_dynamic_typesupport::rosidl_dynamic_typesupport + rosidl_runtime_c::rosidl_runtime_c + rosidl_runtime_cpp::rosidl_runtime_cpp + rosidl_typesupport_cpp::rosidl_typesupport_cpp + ${statistics_msgs_TARGETS} + tracetools::tracetools + ${CMAKE_THREAD_LIBS_INIT} +) + +target_link_libraries(${PROJECT_NAME} PRIVATE + ament_index_cpp::ament_index_cpp + rcl_logging_interface::rcl_logging_interface ) # Causes the visibility macros to use dllexport rather than dllimport, @@ -240,20 +247,23 @@ ament_export_libraries(${PROJECT_NAME}) # Export modern CMake targets ament_export_targets(${PROJECT_NAME}) -# specific order: dependents before dependencies -ament_export_dependencies(ament_index_cpp) -ament_export_dependencies(libstatistics_collector) -ament_export_dependencies(rcl) -ament_export_dependencies(rcpputils) -ament_export_dependencies(rcutils) -ament_export_dependencies(builtin_interfaces) -ament_export_dependencies(rosgraph_msgs) -ament_export_dependencies(rosidl_typesupport_cpp) -ament_export_dependencies(rosidl_typesupport_c) -ament_export_dependencies(rosidl_runtime_cpp) -ament_export_dependencies(rcl_yaml_param_parser) -ament_export_dependencies(statistics_msgs) -ament_export_dependencies(tracetools) +ament_export_dependencies( + builtin_interfaces + libstatistics_collector + rcl + rcl_interfaces + rcl_yaml_param_parser + rcpputils + rcutils + rmw + rosgraph_msgs + rosidl_dynamic_typesupport + rosidl_runtime_c + rosidl_runtime_cpp + rosidl_typesupport_cpp + statistics_msgs + tracetools +) if(BUILD_TESTING) find_package(ament_lint_auto REQUIRED) diff --git a/rclcpp/package.xml b/rclcpp/package.xml index 76480d10f2..0996336d01 100644 --- a/rclcpp/package.xml +++ b/rclcpp/package.xml @@ -22,6 +22,7 @@ builtin_interfaces rcl_interfaces rosgraph_msgs + rosidl_runtime_c rosidl_runtime_cpp rosidl_typesupport_c rosidl_typesupport_cpp @@ -29,6 +30,7 @@ builtin_interfaces rcl_interfaces rosgraph_msgs + rosidl_runtime_c rosidl_runtime_cpp rosidl_typesupport_c rosidl_typesupport_cpp diff --git a/rclcpp/test/benchmark/CMakeLists.txt b/rclcpp/test/benchmark/CMakeLists.txt index a88c43e3b2..6b93711df2 100644 --- a/rclcpp/test/benchmark/CMakeLists.txt +++ b/rclcpp/test/benchmark/CMakeLists.txt @@ -7,14 +7,12 @@ find_package(performance_test_fixture REQUIRED) add_performance_test(benchmark_client benchmark_client.cpp) if(TARGET benchmark_client) - target_link_libraries(benchmark_client ${PROJECT_NAME}) - ament_target_dependencies(benchmark_client test_msgs rcl_interfaces) + target_link_libraries(benchmark_client ${PROJECT_NAME} ${rcl_interfaces_TARGETS} ${test_msgs_TARGETS}) endif() add_performance_test(benchmark_executor benchmark_executor.cpp) if(TARGET benchmark_executor) - target_link_libraries(benchmark_executor ${PROJECT_NAME}) - ament_target_dependencies(benchmark_executor test_msgs) + target_link_libraries(benchmark_executor ${PROJECT_NAME} ${test_msgs_TARGETS}) endif() add_performance_test(benchmark_init_shutdown benchmark_init_shutdown.cpp) @@ -39,6 +37,5 @@ endif() add_performance_test(benchmark_service benchmark_service.cpp) if(TARGET benchmark_service) - target_link_libraries(benchmark_service ${PROJECT_NAME}) - ament_target_dependencies(benchmark_service test_msgs rcl_interfaces) + target_link_libraries(benchmark_service ${PROJECT_NAME} ${rcl_interfaces_TARGETS} ${test_msgs_TARGETS}) endif() diff --git a/rclcpp/test/rclcpp/CMakeLists.txt b/rclcpp/test/rclcpp/CMakeLists.txt index afa12cd24d..ca6c8f2adf 100644 --- a/rclcpp/test/rclcpp/CMakeLists.txt +++ b/rclcpp/test/rclcpp/CMakeLists.txt @@ -36,70 +36,36 @@ endif() ament_add_gtest(test_allocator_memory_strategy strategies/test_allocator_memory_strategy.cpp) if(TARGET test_allocator_memory_strategy) - ament_target_dependencies(test_allocator_memory_strategy - "rcl" - "test_msgs" - ) - target_link_libraries(test_allocator_memory_strategy ${PROJECT_NAME}) + target_link_libraries(test_allocator_memory_strategy ${PROJECT_NAME} rcpputils::rcpputils ${test_msgs_TARGETS}) endif() ament_add_gtest(test_message_pool_memory_strategy strategies/test_message_pool_memory_strategy.cpp) if(TARGET test_message_pool_memory_strategy) - ament_target_dependencies(test_message_pool_memory_strategy - "rcl" - "test_msgs" - ) - target_link_libraries(test_message_pool_memory_strategy ${PROJECT_NAME}) + target_link_libraries(test_message_pool_memory_strategy ${PROJECT_NAME} ${test_msgs_TARGETS}) endif() ament_add_gtest(test_any_service_callback test_any_service_callback.cpp) if(TARGET test_any_service_callback) - ament_target_dependencies(test_any_service_callback - "test_msgs" - ) - target_link_libraries(test_any_service_callback ${PROJECT_NAME}) + target_link_libraries(test_any_service_callback ${PROJECT_NAME} ${test_msgs_TARGETS}) endif() ament_add_gtest(test_any_subscription_callback test_any_subscription_callback.cpp) if(TARGET test_any_subscription_callback) - ament_target_dependencies(test_any_subscription_callback - "test_msgs" - ) - target_link_libraries(test_any_subscription_callback ${PROJECT_NAME}) + target_link_libraries(test_any_subscription_callback ${PROJECT_NAME} ${test_msgs_TARGETS}) endif() ament_add_gtest(test_client test_client.cpp) if(TARGET test_client) - ament_target_dependencies(test_client - "rcl_interfaces" - "rmw" - "rosidl_runtime_cpp" - "rosidl_typesupport_cpp" - "test_msgs" - ) - target_link_libraries(test_client ${PROJECT_NAME} mimick) + target_link_libraries(test_client ${PROJECT_NAME} mimick ${rcl_interfaces_TARGETS} ${test_msgs_TARGETS}) endif() ament_add_gtest(test_copy_all_parameter_values test_copy_all_parameter_values.cpp) if(TARGET test_copy_all_parameter_values) - ament_target_dependencies(test_copy_all_parameter_values - "rcl_interfaces" - ) target_link_libraries(test_copy_all_parameter_values ${PROJECT_NAME}) endif() ament_add_gtest(test_create_timer test_create_timer.cpp) if(TARGET test_create_timer) - ament_target_dependencies(test_create_timer - "rcl_interfaces" - "rmw" - "rcl" - "rosidl_runtime_cpp" - "rosidl_typesupport_cpp" - ) target_link_libraries(test_create_timer ${PROJECT_NAME}) target_include_directories(test_create_timer PRIVATE ./) endif() ament_add_gtest(test_create_subscription test_create_subscription.cpp) if(TARGET test_create_subscription) - target_link_libraries(test_create_subscription ${PROJECT_NAME}) - ament_target_dependencies(test_create_subscription - "test_msgs" - ) + target_link_libraries(test_create_subscription ${PROJECT_NAME} ${test_msgs_TARGETS}) endif() function(test_add_callback_groups_to_executor_for_rmw_implementation) set(rmw_implementation_env_var RMW_IMPLEMENTATION=${rmw_implementation}) @@ -108,32 +74,17 @@ function(test_add_callback_groups_to_executor_for_rmw_implementation) TIMEOUT 120 ) if(TARGET test_add_callback_groups_to_executor${target_suffix}) - target_link_libraries(test_add_callback_groups_to_executor${target_suffix} ${PROJECT_NAME}) - ament_target_dependencies(test_add_callback_groups_to_executor${target_suffix} - "test_msgs" - ) + target_link_libraries(test_add_callback_groups_to_executor${target_suffix} ${PROJECT_NAME} ${test_msgs_TARGETS}) endif() endfunction() call_for_each_rmw_implementation(test_add_callback_groups_to_executor_for_rmw_implementation) ament_add_gtest(test_expand_topic_or_service_name test_expand_topic_or_service_name.cpp) if(TARGET test_expand_topic_or_service_name) - ament_target_dependencies(test_expand_topic_or_service_name - "rcl_interfaces" - "rmw" - "rosidl_runtime_cpp" - "rosidl_typesupport_cpp" - ) - target_link_libraries(test_expand_topic_or_service_name ${PROJECT_NAME} mimick) + target_link_libraries(test_expand_topic_or_service_name ${PROJECT_NAME} mimick rcl::rcl rmw::rmw) endif() ament_add_gtest(test_function_traits test_function_traits.cpp) if(TARGET test_function_traits) - target_include_directories(test_function_traits PUBLIC ../../include) - ament_target_dependencies(test_function_traits - "rcl_interfaces" - "rmw" - "rosidl_runtime_cpp" - "rosidl_typesupport_cpp" - ) + target_link_libraries(test_function_traits ${PROJECT_NAME}) endif() ament_add_gtest( test_future_return_code @@ -143,72 +94,33 @@ if(TARGET test_future_return_code) endif() ament_add_gmock(test_intra_process_manager test_intra_process_manager.cpp) if(TARGET test_intra_process_manager) - ament_target_dependencies(test_intra_process_manager - "rcl" - "rcl_interfaces" - "rmw" - "rosidl_runtime_cpp" - "rosidl_typesupport_cpp" - ) - target_link_libraries(test_intra_process_manager ${PROJECT_NAME}) + target_link_libraries(test_intra_process_manager ${PROJECT_NAME} ${rcl_interfaces_TARGETS} rmw::rmw) endif() ament_add_gmock(test_intra_process_manager_with_allocators test_intra_process_manager_with_allocators.cpp) if(TARGET test_intra_process_manager_with_allocators) - ament_target_dependencies(test_intra_process_manager_with_allocators - "test_msgs" - ) - target_link_libraries(test_intra_process_manager_with_allocators ${PROJECT_NAME}) + target_link_libraries(test_intra_process_manager_with_allocators ${PROJECT_NAME} ${test_msgs_TARGETS}) endif() ament_add_gtest(test_ring_buffer_implementation test_ring_buffer_implementation.cpp) if(TARGET test_ring_buffer_implementation) - ament_target_dependencies(test_ring_buffer_implementation - "rcl_interfaces" - "rmw" - "rosidl_runtime_cpp" - "rosidl_typesupport_cpp" - ) target_link_libraries(test_ring_buffer_implementation ${PROJECT_NAME}) endif() ament_add_gtest(test_intra_process_buffer test_intra_process_buffer.cpp) if(TARGET test_intra_process_buffer) - ament_target_dependencies(test_intra_process_buffer - "rcl_interfaces" - "rmw" - "rosidl_runtime_cpp" - "rosidl_typesupport_cpp" - ) target_link_libraries(test_intra_process_buffer ${PROJECT_NAME}) endif() ament_add_gtest(test_loaned_message test_loaned_message.cpp) -ament_target_dependencies(test_loaned_message - "test_msgs" -) -target_link_libraries(test_loaned_message ${PROJECT_NAME} mimick) +target_link_libraries(test_loaned_message ${PROJECT_NAME} mimick ${test_msgs_TARGETS}) ament_add_gtest(test_memory_strategy test_memory_strategy.cpp) -ament_target_dependencies(test_memory_strategy - "test_msgs" -) -target_link_libraries(test_memory_strategy ${PROJECT_NAME}) +target_link_libraries(test_memory_strategy ${PROJECT_NAME} ${test_msgs_TARGETS}) ament_add_gtest(test_message_memory_strategy test_message_memory_strategy.cpp) -ament_target_dependencies(test_message_memory_strategy - "test_msgs" -) -target_link_libraries(test_message_memory_strategy ${PROJECT_NAME}) +target_link_libraries(test_message_memory_strategy ${PROJECT_NAME} ${test_msgs_TARGETS}) ament_add_gtest(test_node test_node.cpp TIMEOUT 240) if(TARGET test_node) - ament_target_dependencies(test_node - "rcl_interfaces" - "rcpputils" - "rmw" - "rosidl_runtime_cpp" - "rosidl_typesupport_cpp" - "test_msgs" - ) - target_link_libraries(test_node ${PROJECT_NAME} mimick) + target_link_libraries(test_node ${PROJECT_NAME} mimick rcpputils::rcpputils rmw::rmw ${test_msgs_TARGETS}) endif() ament_add_gtest(test_node_interfaces__get_node_interfaces @@ -219,7 +131,7 @@ endif() ament_add_gtest(test_node_interfaces__node_base node_interfaces/test_node_base.cpp) if(TARGET test_node_interfaces__node_base) - target_link_libraries(test_node_interfaces__node_base ${PROJECT_NAME} mimick) + target_link_libraries(test_node_interfaces__node_base ${PROJECT_NAME} mimick rcl::rcl rmw::rmw) endif() ament_add_gtest(test_node_interfaces__node_clock node_interfaces/test_node_clock.cpp) @@ -230,48 +142,42 @@ ament_add_gtest(test_node_interfaces__node_graph node_interfaces/test_node_graph.cpp TIMEOUT 120) if(TARGET test_node_interfaces__node_graph) - ament_target_dependencies( - test_node_interfaces__node_graph - "test_msgs") - target_link_libraries(test_node_interfaces__node_graph ${PROJECT_NAME} mimick) + target_link_libraries(test_node_interfaces__node_graph ${PROJECT_NAME} mimick rcl::rcl ${test_msgs_TARGETS}) endif() ament_add_gtest(test_node_interfaces__node_interfaces node_interfaces/test_node_interfaces.cpp) if(TARGET test_node_interfaces__node_interfaces) - target_link_libraries(test_node_interfaces__node_interfaces ${PROJECT_NAME} mimick) + target_link_libraries(test_node_interfaces__node_interfaces ${PROJECT_NAME}) endif() ament_add_gtest(test_node_interfaces__node_parameters node_interfaces/test_node_parameters.cpp) if(TARGET test_node_interfaces__node_parameters) - target_link_libraries(test_node_interfaces__node_parameters ${PROJECT_NAME} mimick) + target_link_libraries(test_node_interfaces__node_parameters ${PROJECT_NAME} mimick rcpputils::rcpputils) endif() ament_add_gtest(test_node_interfaces__node_services node_interfaces/test_node_services.cpp) if(TARGET test_node_interfaces__node_services) - target_link_libraries(test_node_interfaces__node_services ${PROJECT_NAME} mimick) + target_link_libraries(test_node_interfaces__node_services ${PROJECT_NAME} mimick rcl::rcl) endif() ament_add_gtest(test_node_interfaces__node_timers node_interfaces/test_node_timers.cpp) if(TARGET test_node_interfaces__node_timers) - target_link_libraries(test_node_interfaces__node_timers ${PROJECT_NAME} mimick) + target_link_libraries(test_node_interfaces__node_timers ${PROJECT_NAME} mimick rcl::rcl) endif() ament_add_gtest(test_node_interfaces__node_topics node_interfaces/test_node_topics.cpp) if(TARGET test_node_interfaces__node_topics) - ament_target_dependencies( - test_node_interfaces__node_topics - "test_msgs") - target_link_libraries(test_node_interfaces__node_topics ${PROJECT_NAME} mimick) + target_link_libraries(test_node_interfaces__node_topics ${PROJECT_NAME} mimick rcl::rcl ${test_msgs_TARGETS}) endif() ament_add_gtest(test_node_interfaces__node_type_descriptions node_interfaces/test_node_type_descriptions.cpp) if(TARGET test_node_interfaces__node_type_descriptions) - target_link_libraries(test_node_interfaces__node_type_descriptions ${PROJECT_NAME} mimick) + target_link_libraries(test_node_interfaces__node_type_descriptions ${PROJECT_NAME}) endif() ament_add_gtest(test_node_interfaces__node_waitables node_interfaces/test_node_waitables.cpp) if(TARGET test_node_interfaces__node_waitables) - target_link_libraries(test_node_interfaces__node_waitables ${PROJECT_NAME} mimick) + target_link_libraries(test_node_interfaces__node_waitables ${PROJECT_NAME} mimick rcl::rcl) endif() ament_add_gtest(test_node_interfaces__test_template_utils # Compile time test node_interfaces/detail/test_template_utils.cpp) @@ -302,82 +208,43 @@ endif() ament_add_gtest(test_node_global_args test_node_global_args.cpp) if(TARGET test_node_global_args) - ament_target_dependencies(test_node_global_args - "rcl_interfaces" - "rmw" - "rosidl_runtime_cpp" - "rosidl_typesupport_cpp" - ) target_link_libraries(test_node_global_args ${PROJECT_NAME}) endif() ament_add_gtest(test_node_options test_node_options.cpp) if(TARGET test_node_options) - ament_target_dependencies(test_node_options "rcl") - target_link_libraries(test_node_options ${PROJECT_NAME} mimick) + target_link_libraries(test_node_options ${PROJECT_NAME} mimick rcl::rcl) endif() ament_add_gtest(test_init_options test_init_options.cpp) if(TARGET test_init_options) - ament_target_dependencies(test_init_options "rcl") - target_link_libraries(test_init_options ${PROJECT_NAME} mimick) + target_link_libraries(test_init_options ${PROJECT_NAME} mimick rcl::rcl) endif() ament_add_gmock(test_parameter_client test_parameter_client.cpp) if(TARGET test_parameter_client) - ament_target_dependencies(test_parameter_client - "rcl_interfaces" - ) - target_link_libraries(test_parameter_client ${PROJECT_NAME}) + target_link_libraries(test_parameter_client ${PROJECT_NAME} ${rcl_interfaces_TARGETS}) endif() ament_add_gtest(test_parameter_service test_parameter_service.cpp) if(TARGET test_parameter_service) - ament_target_dependencies(test_parameter_service - "rcl_interfaces" - ) target_link_libraries(test_parameter_service ${PROJECT_NAME}) endif() ament_add_gtest(test_parameter_events_filter test_parameter_events_filter.cpp) if(TARGET test_parameter_events_filter) - ament_target_dependencies(test_parameter_events_filter - "rcl_interfaces" - "rmw" - "rosidl_runtime_cpp" - "rosidl_typesupport_cpp" - ) - target_link_libraries(test_parameter_events_filter ${PROJECT_NAME}) + target_link_libraries(test_parameter_events_filter ${PROJECT_NAME} ${rcl_interfaces_TARGETS}) endif() ament_add_gtest(test_parameter test_parameter.cpp) if(TARGET test_parameter) - ament_target_dependencies(test_parameter - "rcl_interfaces" - "rmw" - "rosidl_runtime_cpp" - "rosidl_typesupport_cpp" - ) target_link_libraries(test_parameter ${PROJECT_NAME}) endif() ament_add_gtest(test_parameter_event_handler test_parameter_event_handler.cpp) if(TARGET test_parameter_event_handler) - ament_target_dependencies(test_parameter_event_handler - "rcl_interfaces" - "rmw" - "rosidl_generator_cpp" - "rosidl_typesupport_cpp" - ) target_link_libraries(test_parameter_event_handler ${PROJECT_NAME}) endif() ament_add_gtest(test_parameter_map test_parameter_map.cpp) if(TARGET test_parameter_map) - target_link_libraries(test_parameter_map ${PROJECT_NAME}) + target_link_libraries(test_parameter_map ${PROJECT_NAME} rcl::rcl rcl_yaml_param_parser::rcl_yaml_param_parser rcutils::rcutils) endif() ament_add_gtest(test_publisher test_publisher.cpp TIMEOUT 120) if(TARGET test_publisher) - ament_target_dependencies(test_publisher - "rcl" - "rmw" - "rosidl_runtime_cpp" - "rosidl_typesupport_cpp" - "test_msgs" - ) - target_link_libraries(test_publisher ${PROJECT_NAME} mimick) + target_link_libraries(test_publisher ${PROJECT_NAME} mimick rcl::rcl rcutils::rcutils ${test_msgs_TARGETS}) endif() set(append_library_dirs "${CMAKE_CURRENT_BINARY_DIR}") @@ -407,32 +274,22 @@ ament_add_gtest(test_subscription_publisher_with_same_type_adapter test_subscrip APPEND_LIBRARY_DIRS "${append_library_dirs}" ) if(TARGET test_subscription_publisher_with_same_type_adapter) - ament_target_dependencies(test_subscription_publisher_with_same_type_adapter - "statistics_msgs" - ) target_link_libraries(test_subscription_publisher_with_same_type_adapter ${PROJECT_NAME} - ${cpp_typesupport_target}) + ${cpp_typesupport_target} + ${statistics_msgs_TARGETS} + ) endif() ament_add_gtest(test_publisher_subscription_count_api test_publisher_subscription_count_api.cpp) if(TARGET test_publisher_subscription_count_api) - ament_target_dependencies(test_publisher_subscription_count_api - "rcl_interfaces" - "rmw" - "rosidl_runtime_cpp" - "rosidl_typesupport_cpp" - "test_msgs" - ) - target_link_libraries(test_publisher_subscription_count_api ${PROJECT_NAME}) + target_link_libraries(test_publisher_subscription_count_api ${PROJECT_NAME} ${test_msgs_TARGETS}) endif() ament_add_gtest(test_qos test_qos.cpp) if(TARGET test_qos) - ament_target_dependencies(test_qos - "rmw" - ) target_link_libraries(test_qos ${PROJECT_NAME} + rmw::rmw ) endif() function(test_generic_pubsub_for_rmw_implementation) @@ -441,12 +298,7 @@ function(test_generic_pubsub_for_rmw_implementation) ENV ${rmw_implementation_env_var} ) if(TARGET test_generic_pubsub${target_suffix}) - target_link_libraries(test_generic_pubsub${target_suffix} ${PROJECT_NAME}) - ament_target_dependencies(test_generic_pubsub${target_suffix} - "rcpputils" - "rosidl_typesupport_cpp" - "test_msgs" - ) + target_link_libraries(test_generic_pubsub${target_suffix} ${PROJECT_NAME} rcl::rcl ${test_msgs_TARGETS}) endif() endfunction() call_for_each_rmw_implementation(test_generic_pubsub_for_rmw_implementation) @@ -457,153 +309,79 @@ function(test_qos_event_for_rmw_implementation) ENV ${rmw_implementation_env_var} ) if(TARGET test_qos_event${target_suffix}) - target_link_libraries(test_qos_event${target_suffix} ${PROJECT_NAME} mimick) - ament_target_dependencies(test_qos_event${target_suffix} - "rmw" - "rosidl_typesupport_cpp" - "test_msgs" - ) + target_link_libraries(test_qos_event${target_suffix} ${PROJECT_NAME} mimick rcutils::rcutils rmw::rmw ${test_msgs_TARGETS}) endif() endfunction() call_for_each_rmw_implementation(test_qos_event_for_rmw_implementation) ament_add_gmock(test_qos_overriding_options test_qos_overriding_options.cpp) if(TARGET test_qos_overriding_options) - target_link_libraries(test_qos_overriding_options - ${PROJECT_NAME} - ) + target_link_libraries(test_qos_overriding_options ${PROJECT_NAME}) endif() ament_add_gmock(test_qos_parameters test_qos_parameters.cpp) if(TARGET test_qos_parameters) - target_link_libraries(test_qos_parameters - ${PROJECT_NAME} - ) + target_link_libraries(test_qos_parameters ${PROJECT_NAME}) endif() ament_add_gtest(test_rate test_rate.cpp) if(TARGET test_rate) - ament_target_dependencies(test_rate - "rcl_interfaces" - "rmw" - "rosidl_runtime_cpp" - "rosidl_typesupport_cpp" - ) - target_link_libraries(test_rate - ${PROJECT_NAME} - ) + target_link_libraries(test_rate ${PROJECT_NAME}) endif() ament_add_gtest(test_serialized_message_allocator test_serialized_message_allocator.cpp) if(TARGET test_serialized_message_allocator) - ament_target_dependencies(test_serialized_message_allocator - test_msgs - ) - target_link_libraries(test_serialized_message_allocator - ${PROJECT_NAME} - ) + target_link_libraries(test_serialized_message_allocator ${PROJECT_NAME} rcl::rcl ${test_msgs_TARGETS}) endif() ament_add_gtest(test_serialized_message test_serialized_message.cpp) if(TARGET test_serialized_message) - ament_target_dependencies(test_serialized_message - test_msgs - ) - target_link_libraries(test_serialized_message - ${PROJECT_NAME} - ) + target_link_libraries(test_serialized_message ${PROJECT_NAME} rcpputils::rcpputils ${test_msgs_TARGETS}) endif() ament_add_gtest(test_service test_service.cpp) if(TARGET test_service) - ament_target_dependencies(test_service - "rcl_interfaces" - "rmw" - "rosidl_runtime_cpp" - "rosidl_typesupport_cpp" - "test_msgs" - ) - target_link_libraries(test_service ${PROJECT_NAME} mimick) + target_link_libraries(test_service ${PROJECT_NAME} mimick ${rcl_interfaces_TARGES} ${test_msgs_TARGETS}) endif() ament_add_gmock(test_service_introspection test_service_introspection.cpp) -if(TARGET test_service) - ament_target_dependencies(test_service_introspection - "rcl_interfaces" - "rmw" - "rosidl_runtime_cpp" - "rosidl_typesupport_cpp" - "test_msgs" - ) - target_link_libraries(test_service_introspection ${PROJECT_NAME} mimick) +if(TARGET test_service_introspection) + target_link_libraries(test_service_introspection ${PROJECT_NAME} mimick ${service_msgs_TARGETS} ${test_msgs_TARGETS}) endif() # Creating and destroying nodes is slow with Connext, so this needs larger timeout. ament_add_gtest(test_subscription test_subscription.cpp TIMEOUT 120) if(TARGET test_subscription) - ament_target_dependencies(test_subscription - "rcl_interfaces" - "rmw" - "rosidl_runtime_cpp" - "rosidl_typesupport_cpp" - "test_msgs" - ) - target_link_libraries(test_subscription ${PROJECT_NAME} mimick) + target_link_libraries(test_subscription ${PROJECT_NAME} mimick ${test_msgs_TARGETS}) endif() ament_add_gtest(test_subscription_publisher_count_api test_subscription_publisher_count_api.cpp) if(TARGET test_subscription_publisher_count_api) - ament_target_dependencies(test_subscription_publisher_count_api - "rcl_interfaces" - "rmw" - "rosidl_runtime_cpp" - "rosidl_typesupport_cpp" - "test_msgs" - ) - target_link_libraries(test_subscription_publisher_count_api ${PROJECT_NAME}) + target_link_libraries(test_subscription_publisher_count_api ${PROJECT_NAME} ${test_msgs_TARGETS}) endif() ament_add_gtest(test_subscription_traits test_subscription_traits.cpp) if(TARGET test_subscription_traits) - ament_target_dependencies(test_subscription_traits - "rcl" - "test_msgs" - ) - target_link_libraries(test_subscription_traits ${PROJECT_NAME}) + target_link_libraries(test_subscription_traits ${PROJECT_NAME} rcl::rcl ${test_msgs_TARGETS}) endif() ament_add_gtest(test_type_support test_type_support.cpp) if(TARGET test_type_support) - ament_target_dependencies(test_type_support - "rmw" - "rosidl_runtime_cpp" - "rosidl_typesupport_cpp" - "test_msgs" - ) - target_link_libraries(test_type_support ${PROJECT_NAME}) + target_link_libraries(test_type_support ${PROJECT_NAME} ${test_msgs_TARGETS}) endif() ament_add_gmock(test_typesupport_helpers test_typesupport_helpers.cpp) if(TARGET test_typesupport_helpers) - target_link_libraries(test_typesupport_helpers ${PROJECT_NAME}) + target_link_libraries(test_typesupport_helpers ${PROJECT_NAME} rcpputils::rcpputils) endif() ament_add_gtest(test_find_weak_nodes test_find_weak_nodes.cpp) if(TARGET test_find_weak_nodes) - ament_target_dependencies(test_find_weak_nodes - "rcl" - ) target_link_libraries(test_find_weak_nodes ${PROJECT_NAME}) endif() ament_add_gtest(test_externally_defined_services test_externally_defined_services.cpp) -ament_target_dependencies(test_externally_defined_services - "rcl" - "test_msgs" -) -target_link_libraries(test_externally_defined_services ${PROJECT_NAME}) +target_link_libraries(test_externally_defined_services ${PROJECT_NAME} rcl::rcl ${test_msgs_TARGETS}) ament_add_gtest(test_duration test_duration.cpp APPEND_LIBRARY_DIRS "${append_library_dirs}") if(TARGET test_duration) - ament_target_dependencies(test_duration - "rcl") - target_link_libraries(test_duration ${PROJECT_NAME}) + target_link_libraries(test_duration ${PROJECT_NAME} rcl::rcl) endif() ament_add_gtest(test_logger test_logger.cpp) -target_link_libraries(test_logger ${PROJECT_NAME}) +target_link_libraries(test_logger ${PROJECT_NAME} rcutils::rcutils) ament_add_gmock(test_logging test_logging.cpp) -target_link_libraries(test_logging ${PROJECT_NAME}) +target_link_libraries(test_logging ${PROJECT_NAME} rcutils::rcutils) ament_add_gmock(test_context test_context.cpp) target_link_libraries(test_context ${PROJECT_NAME}) @@ -611,62 +389,46 @@ target_link_libraries(test_context ${PROJECT_NAME}) ament_add_gtest(test_time test_time.cpp APPEND_LIBRARY_DIRS "${append_library_dirs}") if(TARGET test_time) - ament_target_dependencies(test_time - "rcl") - target_link_libraries(test_time ${PROJECT_NAME}) + target_link_libraries(test_time ${PROJECT_NAME} rcl::rcl rcutils::rcutils) endif() ament_add_gtest(test_timer test_timer.cpp APPEND_LIBRARY_DIRS "${append_library_dirs}") if(TARGET test_timer) - ament_target_dependencies(test_timer - "rcl") - target_link_libraries(test_timer ${PROJECT_NAME} mimick) + target_link_libraries(test_timer ${PROJECT_NAME} mimick rcl::rcl) endif() ament_add_gtest(test_timers_manager test_timers_manager.cpp APPEND_LIBRARY_DIRS "${append_library_dirs}") if(TARGET test_timers_manager) - ament_target_dependencies(test_timers_manager - "rcl") - target_link_libraries(test_timers_manager ${PROJECT_NAME} mimick) + target_link_libraries(test_timers_manager ${PROJECT_NAME}) endif() ament_add_gtest(test_time_source test_time_source.cpp APPEND_LIBRARY_DIRS "${append_library_dirs}") if(TARGET test_time_source) - ament_target_dependencies(test_time_source - "rcl") - target_link_libraries(test_time_source ${PROJECT_NAME}) + target_link_libraries(test_time_source ${PROJECT_NAME} rcl::rcl) endif() ament_add_gtest(test_utilities test_utilities.cpp APPEND_LIBRARY_DIRS "${append_library_dirs}") if(TARGET test_utilities) - ament_target_dependencies(test_utilities - "rcl") - target_link_libraries(test_utilities ${PROJECT_NAME} mimick) + target_link_libraries(test_utilities ${PROJECT_NAME} mimick rcl::rcl) endif() ament_add_gtest(test_wait_for_message test_wait_for_message.cpp) if(TARGET test_wait_for_message) - ament_target_dependencies(test_wait_for_message - "test_msgs") - target_link_libraries(test_wait_for_message ${PROJECT_NAME}) + target_link_libraries(test_wait_for_message ${PROJECT_NAME} ${test_msgs_TARGETS}) endif() ament_add_gtest(test_logger_service test_logger_service.cpp) if(TARGET test_logger_service) - ament_target_dependencies(test_logger_service - "rcl_interfaces") - target_link_libraries(test_logger_service ${PROJECT_NAME}) + target_link_libraries(test_logger_service ${PROJECT_NAME} ${rcl_interfaces_TARGETS}) endif() ament_add_gtest(test_interface_traits test_interface_traits.cpp APPEND_LIBRARY_DIRS "${append_library_dirs}") if(TARGET test_interface_traits) - ament_target_dependencies(test_interface_traits - "rcl") target_link_libraries(test_interface_traits ${PROJECT_NAME}) endif() @@ -676,67 +438,47 @@ ament_add_gtest( APPEND_LIBRARY_DIRS "${append_library_dirs}" TIMEOUT 180) if(TARGET test_executors) - ament_target_dependencies(test_executors - "rcl" - "test_msgs") - target_link_libraries(test_executors ${PROJECT_NAME}) + target_link_libraries(test_executors ${PROJECT_NAME} rcl::rcl ${test_msgs_TARGETS}) endif() ament_add_gtest(test_static_single_threaded_executor executors/test_static_single_threaded_executor.cpp APPEND_LIBRARY_DIRS "${append_library_dirs}") if(TARGET test_static_single_threaded_executor) - ament_target_dependencies(test_static_single_threaded_executor - "test_msgs") - target_link_libraries(test_static_single_threaded_executor ${PROJECT_NAME} mimick) + target_link_libraries(test_static_single_threaded_executor ${PROJECT_NAME} mimick ${test_msgs_TARGETS}) endif() ament_add_gtest(test_multi_threaded_executor executors/test_multi_threaded_executor.cpp APPEND_LIBRARY_DIRS "${append_library_dirs}") if(TARGET test_multi_threaded_executor) - ament_target_dependencies(test_multi_threaded_executor - "rcl") target_link_libraries(test_multi_threaded_executor ${PROJECT_NAME}) endif() ament_add_gtest(test_static_executor_entities_collector executors/test_static_executor_entities_collector.cpp APPEND_LIBRARY_DIRS "${append_library_dirs}" TIMEOUT 120) if(TARGET test_static_executor_entities_collector) - ament_target_dependencies(test_static_executor_entities_collector - "rcl" - "test_msgs") - target_link_libraries(test_static_executor_entities_collector ${PROJECT_NAME} mimick) + target_link_libraries(test_static_executor_entities_collector ${PROJECT_NAME} mimick rcpputils::rcpputils ${test_msgs_TARGETS}) endif() ament_add_gtest(test_entities_collector executors/test_entities_collector.cpp APPEND_LIBRARY_DIRS "${append_library_dirs}" TIMEOUT 120) if(TARGET test_entities_collector) - ament_target_dependencies(test_entities_collector - "rcl" - "test_msgs") - target_link_libraries(test_entities_collector ${PROJECT_NAME} mimick) + target_link_libraries(test_entities_collector ${PROJECT_NAME}) endif() ament_add_gtest(test_executor_notify_waitable executors/test_executor_notify_waitable.cpp APPEND_LIBRARY_DIRS "${append_library_dirs}" TIMEOUT 120) if(TARGET test_executor_notify_waitable) - ament_target_dependencies(test_executor_notify_waitable - "rcl" - "test_msgs") - target_link_libraries(test_executor_notify_waitable ${PROJECT_NAME} mimick) + target_link_libraries(test_executor_notify_waitable ${PROJECT_NAME} mimick rcpputils::rcpputils) endif() ament_add_gtest(test_events_executor executors/test_events_executor.cpp TIMEOUT 5) if(TARGET test_events_executor) - ament_target_dependencies(test_events_executor - "test_msgs") - target_link_libraries(test_events_executor ${PROJECT_NAME}) + target_link_libraries(test_events_executor ${PROJECT_NAME} ${test_msgs_TARGETS}) endif() ament_add_gtest(test_events_queue executors/test_events_queue.cpp APPEND_LIBRARY_DIRS "${append_library_dirs}") if(TARGET test_events_queue) - ament_target_dependencies(test_events_queue - "test_msgs") target_link_libraries(test_events_queue ${PROJECT_NAME}) endif() @@ -749,76 +491,60 @@ endif() ament_add_gtest(test_wait_set test_wait_set.cpp APPEND_LIBRARY_DIRS "${append_library_dirs}") if(TARGET test_wait_set) - ament_target_dependencies(test_wait_set "test_msgs") - target_link_libraries(test_wait_set ${PROJECT_NAME}) + target_link_libraries(test_wait_set ${PROJECT_NAME} ${rcl_interfaces_TARGETS} ${test_msgs_TARGETS}) endif() ament_add_gtest(test_subscription_topic_statistics topic_statistics/test_subscription_topic_statistics.cpp APPEND_LIBRARY_DIRS "${append_library_dirs}" ) if(TARGET test_subscription_topic_statistics) - ament_target_dependencies(test_subscription_topic_statistics - "builtin_interfaces" - "libstatistics_collector" - "rcl_interfaces" - "rcutils" - "rmw" - "rosidl_runtime_cpp" - "rosidl_typesupport_cpp" - "statistics_msgs" - "test_msgs") target_link_libraries(test_subscription_topic_statistics ${PROJECT_NAME} - ${cpp_typesupport_target}) + libstatistics_collector::libstatistics_collector + ${statistics_msgs_TARGETS} + ${test_msgs_TARGETS} + ) endif() ament_add_gtest(test_subscription_options test_subscription_options.cpp) if(TARGET test_subscription_options) - ament_target_dependencies(test_subscription_options "rcl") target_link_libraries(test_subscription_options ${PROJECT_NAME}) endif() ament_add_gtest(test_dynamic_storage wait_set_policies/test_dynamic_storage.cpp) if(TARGET test_dynamic_storage) - ament_target_dependencies(test_dynamic_storage "rcl" "test_msgs") - target_link_libraries(test_dynamic_storage ${PROJECT_NAME}) + target_link_libraries(test_dynamic_storage ${PROJECT_NAME} ${test_msgs_TARGETS}) endif() ament_add_gtest(test_storage_policy_common wait_set_policies/test_storage_policy_common.cpp) if(TARGET test_storage_policy_common) - ament_target_dependencies(test_storage_policy_common "rcl" "test_msgs") - target_link_libraries(test_storage_policy_common ${PROJECT_NAME} mimick) + target_link_libraries(test_storage_policy_common ${PROJECT_NAME} mimick ${test_msgs_TARGETS}) endif() ament_add_gtest(test_static_storage wait_set_policies/test_static_storage.cpp) if(TARGET test_static_storage) - ament_target_dependencies(test_static_storage "rcl" "test_msgs") - target_link_libraries(test_static_storage ${PROJECT_NAME}) + target_link_libraries(test_static_storage ${PROJECT_NAME} ${test_msgs_TARGETS}) endif() ament_add_gtest(test_thread_safe_synchronization wait_set_policies/test_thread_safe_synchronization.cpp) if(TARGET test_thread_safe_synchronization) - ament_target_dependencies(test_thread_safe_synchronization "rcl" "test_msgs") - target_link_libraries(test_thread_safe_synchronization ${PROJECT_NAME}) + target_link_libraries(test_thread_safe_synchronization ${PROJECT_NAME} ${test_msgs_TARGETS}) endif() ament_add_gtest(test_rosout_qos test_rosout_qos.cpp) if(TARGET test_rosout_qos) - ament_target_dependencies(test_rosout_qos "rcl") - target_link_libraries(test_rosout_qos ${PROJECT_NAME}) + target_link_libraries(test_rosout_qos ${PROJECT_NAME} rcl::rcl rmw::rmw) endif() ament_add_gtest(test_rosout_subscription test_rosout_subscription.cpp) if(TARGET test_rosout_subscription) - ament_target_dependencies(test_rosout_subscription "rcl") - target_link_libraries(test_rosout_subscription ${PROJECT_NAME}) + target_link_libraries(test_rosout_subscription ${PROJECT_NAME} ${rcl_interfaces_TARGETS}) endif() ament_add_gtest(test_executor test_executor.cpp APPEND_LIBRARY_DIRS "${append_library_dirs}" TIMEOUT 120) if(TARGET test_executor) - ament_target_dependencies(test_executor "rcl") target_link_libraries(test_executor ${PROJECT_NAME} mimick) endif() @@ -835,12 +561,7 @@ function(test_subscription_content_filter_for_rmw_implementation) TIMEOUT 120 ) if(TARGET test_subscription_content_filter${target_suffix}) - target_link_libraries(test_subscription_content_filter${target_suffix} ${PROJECT_NAME} mimick) - ament_target_dependencies(test_subscription_content_filter${target_suffix} - "rcpputils" - "rosidl_typesupport_cpp" - "test_msgs" - ) + target_link_libraries(test_subscription_content_filter${target_suffix} ${PROJECT_NAME} mimick ${test_msgs_TARGETS}) endif() endfunction() call_for_each_rmw_implementation(test_subscription_content_filter_for_rmw_implementation) diff --git a/rclcpp_action/CMakeLists.txt b/rclcpp_action/CMakeLists.txt index 785ed0e5e1..647a820969 100644 --- a/rclcpp_action/CMakeLists.txt +++ b/rclcpp_action/CMakeLists.txt @@ -5,6 +5,7 @@ project(rclcpp_action) find_package(ament_cmake_ros REQUIRED) find_package(action_msgs REQUIRED) find_package(rclcpp REQUIRED) +find_package(rcl REQUIRED) find_package(rcl_action REQUIRED) find_package(rcpputils REQUIRED) find_package(rosidl_runtime_c REQUIRED) @@ -21,28 +22,26 @@ if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") ) endif() -set(${PROJECT_NAME}_SRCS +add_library(${PROJECT_NAME} src/client.cpp src/qos.cpp src/server.cpp src/server_goal_handle.cpp src/types.cpp ) - -add_library(${PROJECT_NAME} - ${${PROJECT_NAME}_SRCS}) - target_include_directories(${PROJECT_NAME} PUBLIC "$" "$") - -ament_target_dependencies(${PROJECT_NAME} - "action_msgs" - "rcl_action" - "rclcpp" - "rcpputils" - "rosidl_runtime_c" +target_link_libraries(${PROJECT_NAME} PUBLIC + ${action_msgs_TARGETS} + rcl::rcl + rcl_action::rcl_action + rclcpp::rclcpp + rosidl_runtime_c::rosidl_runtime_c +) +target_link_libraries(${PROJECT_NAME} PRIVATE + rcpputils::rcpputils ) # Causes the visibility macros to use dllexport rather than dllimport, @@ -69,12 +68,7 @@ ament_export_libraries(${PROJECT_NAME}) # Export modern CMake targets ament_export_targets(${PROJECT_NAME}) -# specific order: dependents before dependencies -ament_export_dependencies(ament_cmake) -ament_export_dependencies(action_msgs) -ament_export_dependencies(rclcpp) -ament_export_dependencies(rcl_action) -ament_export_dependencies(rosidl_runtime_c) +ament_export_dependencies(action_msgs rcl_action rclcpp rosidl_runtime_c) if(BUILD_TESTING) find_package(ament_cmake_gtest REQUIRED) @@ -87,58 +81,52 @@ if(BUILD_TESTING) ament_add_gtest(test_client test/test_client.cpp TIMEOUT 180) if(TARGET test_client) - ament_target_dependencies(test_client - "rcutils" - "test_msgs" - ) target_link_libraries(test_client ${PROJECT_NAME} mimick + rcl::rcl + rcl_action::rcl_action + rclcpp::rclcpp + rcutils::rcutils + ${test_msgs_TARGETS} ) endif() ament_add_gtest(test_server test/test_server.cpp TIMEOUT 180) if(TARGET test_server) - ament_target_dependencies(test_server - "rcpputils" - "rcutils" - "test_msgs" - ) target_link_libraries(test_server ${PROJECT_NAME} mimick + rcl_action::rcl_action + rclcpp::rclcpp + ${test_msgs_TARGETS} ) endif() ament_add_gtest(test_server_goal_handle test/test_server_goal_handle.cpp) if(TARGET test_server_goal_handle) - ament_target_dependencies(test_server_goal_handle - "rcutils" - "test_msgs" - ) target_link_libraries(test_server_goal_handle ${PROJECT_NAME} + ${action_msgs_TARGETS} mimick + rclcpp::rclcpp + ${test_msgs_TARGETS} ) endif() ament_add_gtest(test_traits test/test_traits.cpp) if(TARGET test_traits) - ament_target_dependencies(test_traits - "test_msgs" - ) target_link_libraries(test_traits ${PROJECT_NAME} + ${test_msgs_TARGETS} ) endif() ament_add_gtest(test_types test/test_types.cpp) if(TARGET test_types) - ament_target_dependencies(test_types - "test_msgs" - ) target_link_libraries(test_types ${PROJECT_NAME} + ${test_msgs_TARGETS} ) endif() endif() diff --git a/rclcpp_action/package.xml b/rclcpp_action/package.xml index 105ead1894..2cd65a86f1 100644 --- a/rclcpp_action/package.xml +++ b/rclcpp_action/package.xml @@ -23,6 +23,7 @@ action_msgs rclcpp rcl_action + rcl rcpputils ament_cmake diff --git a/rclcpp_action/test/benchmark/CMakeLists.txt b/rclcpp_action/test/benchmark/CMakeLists.txt index dc87c553af..0ce6c6245c 100644 --- a/rclcpp_action/test/benchmark/CMakeLists.txt +++ b/rclcpp_action/test/benchmark/CMakeLists.txt @@ -9,8 +9,7 @@ add_performance_test( benchmark_action_client.cpp TIMEOUT 240) if(TARGET benchmark_action_client) - target_link_libraries(benchmark_action_client ${PROJECT_NAME}) - ament_target_dependencies(benchmark_action_client rclcpp test_msgs) + target_link_libraries(benchmark_action_client ${PROJECT_NAME} rclcpp::rclcpp ${test_msgs_TARGETS}) endif() add_performance_test( @@ -18,6 +17,5 @@ add_performance_test( benchmark_action_server.cpp TIMEOUT 120) if(TARGET benchmark_action_server) - target_link_libraries(benchmark_action_server ${PROJECT_NAME}) - ament_target_dependencies(benchmark_action_server rclcpp test_msgs) + target_link_libraries(benchmark_action_server ${PROJECT_NAME} rclcpp::rclcpp ${test_msgs_TARGETS}) endif() diff --git a/rclcpp_components/CMakeLists.txt b/rclcpp_components/CMakeLists.txt index 121ef434c2..7d4135051c 100644 --- a/rclcpp_components/CMakeLists.txt +++ b/rclcpp_components/CMakeLists.txt @@ -21,7 +21,7 @@ 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 an interface library that can be depended upon by libraries who register components add_library(component INTERFACE) target_include_directories(component INTERFACE "$" @@ -38,12 +38,14 @@ add_library( target_include_directories(component_manager PUBLIC "$" "$") -ament_target_dependencies(component_manager - "ament_index_cpp" - "class_loader" - "composition_interfaces" - "rclcpp" - "rcpputils" +target_link_libraries(component_manager PUBLIC + ${composition_interfaces_TARGETS} + rclcpp::rclcpp +) +target_link_libraries(component_manager PRIVATE + ament_index_cpp::ament_index_cpp + class_loader::class_loader + rcpputils::rcpputils ) target_compile_definitions(component_manager PRIVATE "RCLCPP_COMPONENTS_BUILDING_LIBRARY") @@ -52,10 +54,7 @@ add_executable( component_container src/component_container.cpp ) -target_link_libraries(component_container component_manager) -ament_target_dependencies(component_container - "rclcpp" -) +target_link_libraries(component_container component_manager rclcpp::rclcpp) set(node_main_template_install_dir "share/${PROJECT_NAME}") install(FILES @@ -66,20 +65,13 @@ add_executable( component_container_mt src/component_container_mt.cpp ) -target_link_libraries(component_container_mt component_manager) -ament_target_dependencies(component_container_mt - "rclcpp" -) +target_link_libraries(component_container_mt component_manager rclcpp::rclcpp) add_executable( component_container_isolated src/component_container_isolated.cpp ) -target_link_libraries(component_container_isolated component_manager) -ament_target_dependencies(component_container_isolated - "rclcpp" -) - +target_link_libraries(component_container_isolated component_manager rclcpp::rclcpp) if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") target_link_libraries(component_container "stdc++fs") diff --git a/rclcpp_components/cmake/rclcpp_components_register_node.cmake b/rclcpp_components/cmake/rclcpp_components_register_node.cmake index c5b87af667..e78bb3650c 100644 --- a/rclcpp_components/cmake/rclcpp_components_register_node.cmake +++ b/rclcpp_components/cmake/rclcpp_components_register_node.cmake @@ -70,10 +70,11 @@ macro(rclcpp_components_register_node target) file(GENERATE OUTPUT ${PROJECT_BINARY_DIR}/rclcpp_components/node_main_${node}.cpp INPUT ${PROJECT_BINARY_DIR}/rclcpp_components/node_main_configured_${node}.cpp.in) add_executable(${node} ${PROJECT_BINARY_DIR}/rclcpp_components/node_main_${node}.cpp) - ament_target_dependencies(${node} - "rclcpp" - "class_loader" - "rclcpp_components") + target_link_libraries(${node} + class_loader::class_loader + rclcpp::rclcpp + rclcpp_components::component + ) install(TARGETS ${node} DESTINATION lib/${PROJECT_NAME})