Skip to content

Commit 9ea5fee

Browse files
authored
Use target_link_libraries instead of ament_target_dependencies (ros2#404)
Signed-off-by: Shane Loretz <[email protected]>
1 parent 4a4082a commit 9ea5fee

File tree

12 files changed

+61
-67
lines changed

12 files changed

+61
-67
lines changed

rclcpp/actions/minimal_action_client/CMakeLists.txt

+16-16
Original file line numberDiff line numberDiff line change
@@ -17,28 +17,28 @@ find_package(rclcpp REQUIRED)
1717
find_package(rclcpp_action REQUIRED)
1818

1919
add_executable(action_client_member_functions member_functions.cpp)
20-
ament_target_dependencies(action_client_member_functions
21-
"rclcpp"
22-
"rclcpp_action"
23-
"example_interfaces")
20+
target_link_libraries(action_client_member_functions PRIVATE
21+
${example_interfaces_TARGETS}
22+
rclcpp::rclcpp
23+
rclcpp_action::rclcpp_action)
2424

2525
add_executable(action_client_not_composable not_composable.cpp)
26-
ament_target_dependencies(action_client_not_composable
27-
"rclcpp"
28-
"rclcpp_action"
29-
"example_interfaces")
26+
target_link_libraries(action_client_not_composable PRIVATE
27+
${example_interfaces_TARGETS}
28+
rclcpp::rclcpp
29+
rclcpp_action::rclcpp_action)
3030

3131
add_executable(action_client_not_composable_with_cancel not_composable_with_cancel.cpp)
32-
ament_target_dependencies(action_client_not_composable_with_cancel
33-
"rclcpp"
34-
"rclcpp_action"
35-
"example_interfaces")
32+
target_link_libraries(action_client_not_composable_with_cancel PRIVATE
33+
${example_interfaces_TARGETS}
34+
rclcpp::rclcpp
35+
rclcpp_action::rclcpp_action)
3636

3737
add_executable(action_client_not_composable_with_feedback not_composable_with_feedback.cpp)
38-
ament_target_dependencies(action_client_not_composable_with_feedback
39-
"rclcpp"
40-
"rclcpp_action"
41-
"example_interfaces")
38+
target_link_libraries(action_client_not_composable_with_feedback PRIVATE
39+
${example_interfaces_TARGETS}
40+
rclcpp::rclcpp
41+
rclcpp_action::rclcpp_action)
4242

4343
if(BUILD_TESTING)
4444
find_package(ament_lint_auto REQUIRED)

rclcpp/actions/minimal_action_server/CMakeLists.txt

+8-8
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,16 @@ find_package(rclcpp REQUIRED)
1717
find_package(rclcpp_action REQUIRED)
1818

1919
add_executable(action_server_member_functions member_functions.cpp)
20-
ament_target_dependencies(action_server_member_functions
21-
"rclcpp"
22-
"rclcpp_action"
23-
"example_interfaces")
20+
target_link_libraries(action_server_member_functions PRIVATE
21+
${example_interfaces_TARGETS}
22+
rclcpp::rclcpp
23+
rclcpp_action::rclcpp_action)
2424

2525
add_executable(action_server_not_composable not_composable.cpp)
26-
ament_target_dependencies(action_server_not_composable
27-
"rclcpp"
28-
"rclcpp_action"
29-
"example_interfaces")
26+
target_link_libraries(action_server_not_composable PRIVATE
27+
${example_interfaces_TARGETS}
28+
rclcpp::rclcpp
29+
rclcpp_action::rclcpp_action)
3030

3131
if(BUILD_TESTING)
3232
find_package(ament_lint_auto REQUIRED)

rclcpp/composition/minimal_composition/CMakeLists.txt

+4-9
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ add_library(composition_nodes SHARED
2323
src/subscriber_node.cpp)
2424
target_compile_definitions(composition_nodes
2525
PRIVATE "MINIMAL_COMPOSITION_DLL")
26-
ament_target_dependencies(composition_nodes rclcpp rclcpp_components std_msgs)
26+
target_link_libraries(composition_nodes PUBLIC rclcpp::rclcpp rclcpp_components::component ${std_msgs_TARGETS})
2727

2828
# This package installs libraries without exporting them.
2929
# Export the library path to ensure that the installed libraries are available.
@@ -33,18 +33,13 @@ if(NOT WIN32)
3333
endif()
3434

3535
add_executable(composition_publisher src/standalone_publisher.cpp)
36-
target_link_libraries(composition_publisher composition_nodes)
37-
ament_target_dependencies(composition_publisher
38-
rclcpp)
36+
target_link_libraries(composition_publisher PRIVATE composition_nodes rclcpp::rclcpp)
3937

4038
add_executable(composition_subscriber src/standalone_subscriber.cpp)
41-
target_link_libraries(composition_subscriber composition_nodes)
42-
ament_target_dependencies(composition_subscriber
43-
rclcpp)
39+
target_link_libraries(composition_subscriber PRIVATE composition_nodes rclcpp::rclcpp)
4440

4541
add_executable(composition_composed src/composed.cpp)
46-
target_link_libraries(composition_composed composition_nodes)
47-
ament_target_dependencies(composition_composed rclcpp class_loader)
42+
target_link_libraries(composition_composed PRIVATE composition_nodes rclcpp::rclcpp class_loader::class_loader)
4843

4944
install(TARGETS
5045
composition_nodes

rclcpp/executors/cbg_executor/CMakeLists.txt

+3-3
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,15 @@ add_executable(
2121
src/examples_rclcpp_cbg_executor/ping_node.cpp
2222
)
2323
target_include_directories(ping PUBLIC include)
24-
ament_target_dependencies(ping rclcpp std_msgs)
24+
target_link_libraries(ping PRIVATE rclcpp::rclcpp ${std_msgs_TARGETS})
2525

2626
add_executable(
2727
pong
2828
src/pong.cpp
2929
src/examples_rclcpp_cbg_executor/pong_node.cpp
3030
)
3131
target_include_directories(pong PUBLIC include)
32-
ament_target_dependencies(pong rclcpp std_msgs)
32+
target_link_libraries(pong PRIVATE rclcpp::rclcpp ${std_msgs_TARGETS})
3333

3434
add_executable(
3535
ping_pong
@@ -38,7 +38,7 @@ add_executable(
3838
src/examples_rclcpp_cbg_executor/pong_node.cpp
3939
)
4040
target_include_directories(ping_pong PUBLIC include)
41-
ament_target_dependencies(ping_pong rclcpp std_msgs)
41+
target_link_libraries(ping_pong PRIVATE rclcpp::rclcpp ${std_msgs_TARGETS})
4242

4343
install(TARGETS ping pong ping_pong
4444
DESTINATION lib/${PROJECT_NAME}

rclcpp/executors/multithreaded_executor/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ find_package(rclcpp REQUIRED)
1616
find_package(std_msgs REQUIRED)
1717

1818
add_executable(multithreaded_executor multithreaded_executor.cpp)
19-
ament_target_dependencies(multithreaded_executor rclcpp std_msgs)
19+
target_link_libraries(multithreaded_executor PRIVATE rclcpp::rclcpp ${std_msgs_TARGETS})
2020

2121
install(TARGETS
2222
multithreaded_executor

rclcpp/services/async_client/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ find_package(example_interfaces REQUIRED)
1616
find_package(rclcpp REQUIRED)
1717

1818
add_executable(client_main main.cpp)
19-
ament_target_dependencies(client_main rclcpp example_interfaces)
19+
target_link_libraries(client_main PRIVATE rclcpp::rclcpp ${example_interfaces_TARGETS})
2020

2121
install(TARGETS client_main
2222
DESTINATION lib/${PROJECT_NAME})

rclcpp/services/minimal_client/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ find_package(example_interfaces REQUIRED)
1616
find_package(rclcpp REQUIRED)
1717

1818
add_executable(client_main main.cpp)
19-
ament_target_dependencies(client_main rclcpp example_interfaces)
19+
target_link_libraries(client_main PRIVATE rclcpp::rclcpp ${example_interfaces_TARGETS})
2020

2121
install(TARGETS client_main
2222
DESTINATION lib/${PROJECT_NAME})

rclcpp/services/minimal_service/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ find_package(example_interfaces REQUIRED)
1616
find_package(rclcpp REQUIRED)
1717

1818
add_executable(service_main main.cpp)
19-
ament_target_dependencies(service_main rclcpp example_interfaces)
19+
target_link_libraries(service_main PRIVATE rclcpp::rclcpp ${example_interfaces_TARGETS})
2020

2121
install(TARGETS service_main
2222
DESTINATION lib/${PROJECT_NAME})

rclcpp/timers/minimal_timer/CMakeLists.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ find_package(ament_cmake REQUIRED)
1515
find_package(rclcpp REQUIRED)
1616

1717
add_executable(timer_lambda lambda.cpp)
18-
ament_target_dependencies(timer_lambda rclcpp)
18+
target_link_libraries(timer_lambda PRIVATE rclcpp::rclcpp)
1919

2020
add_executable(timer_member_function member_function.cpp)
21-
ament_target_dependencies(timer_member_function rclcpp)
21+
target_link_libraries(timer_member_function PRIVATE rclcpp::rclcpp)
2222

2323
install(TARGETS
2424
timer_lambda

rclcpp/topics/minimal_publisher/CMakeLists.txt

+6-6
Original file line numberDiff line numberDiff line change
@@ -16,22 +16,22 @@ find_package(rclcpp REQUIRED)
1616
find_package(std_msgs REQUIRED)
1717

1818
add_executable(publisher_lambda lambda.cpp)
19-
ament_target_dependencies(publisher_lambda rclcpp std_msgs)
19+
target_link_libraries(publisher_lambda PRIVATE rclcpp::rclcpp ${std_msgs_TARGETS})
2020

2121
add_executable(publisher_member_function member_function.cpp)
22-
ament_target_dependencies(publisher_member_function rclcpp std_msgs)
22+
target_link_libraries(publisher_member_function PRIVATE rclcpp::rclcpp ${std_msgs_TARGETS})
2323

2424
add_executable(publisher_member_function_with_type_adapter member_function_with_type_adapter.cpp)
25-
ament_target_dependencies(publisher_member_function_with_type_adapter rclcpp std_msgs)
25+
target_link_libraries(publisher_member_function_with_type_adapter PRIVATE rclcpp::rclcpp ${std_msgs_TARGETS})
2626

2727
add_executable(publisher_member_function_with_unique_network_flow_endpoints member_function_with_unique_network_flow_endpoints.cpp)
28-
ament_target_dependencies(publisher_member_function_with_unique_network_flow_endpoints rclcpp std_msgs)
28+
target_link_libraries(publisher_member_function_with_unique_network_flow_endpoints PRIVATE rclcpp::rclcpp ${std_msgs_TARGETS})
2929

3030
add_executable(publisher_wait_for_all_acked member_function_with_wait_for_all_acked.cpp)
31-
ament_target_dependencies(publisher_wait_for_all_acked rclcpp std_msgs)
31+
target_link_libraries(publisher_wait_for_all_acked PRIVATE rclcpp::rclcpp ${std_msgs_TARGETS})
3232

3333
add_executable(publisher_not_composable not_composable.cpp)
34-
ament_target_dependencies(publisher_not_composable rclcpp std_msgs)
34+
target_link_libraries(publisher_not_composable PRIVATE rclcpp::rclcpp ${std_msgs_TARGETS})
3535

3636
install(TARGETS
3737
publisher_lambda

rclcpp/topics/minimal_subscriber/CMakeLists.txt

+8-8
Original file line numberDiff line numberDiff line change
@@ -17,31 +17,31 @@ find_package(rclcpp_components REQUIRED)
1717
find_package(std_msgs REQUIRED)
1818

1919
add_executable(subscriber_lambda lambda.cpp)
20-
ament_target_dependencies(subscriber_lambda rclcpp std_msgs)
20+
target_link_libraries(subscriber_lambda PRIVATE rclcpp::rclcpp ${std_msgs_TARGETS})
2121

2222
add_executable(subscriber_member_function member_function.cpp)
23-
ament_target_dependencies(subscriber_member_function rclcpp std_msgs)
23+
target_link_libraries(subscriber_member_function PRIVATE rclcpp::rclcpp ${std_msgs_TARGETS})
2424

2525
add_executable(subscriber_member_function_with_topic_statistics member_function_with_topic_statistics.cpp)
26-
ament_target_dependencies(subscriber_member_function_with_topic_statistics rclcpp std_msgs)
26+
target_link_libraries(subscriber_member_function_with_topic_statistics PRIVATE rclcpp::rclcpp ${std_msgs_TARGETS})
2727

2828
add_executable(subscriber_member_function_with_type_adapter member_function_with_type_adapter.cpp)
29-
ament_target_dependencies(subscriber_member_function_with_type_adapter rclcpp std_msgs)
29+
target_link_libraries(subscriber_member_function_with_type_adapter PRIVATE rclcpp::rclcpp ${std_msgs_TARGETS})
3030

3131
add_executable(subscriber_member_function_with_unique_network_flow_endpoints member_function_with_unique_network_flow_endpoints.cpp)
32-
ament_target_dependencies(subscriber_member_function_with_unique_network_flow_endpoints rclcpp std_msgs)
32+
target_link_libraries(subscriber_member_function_with_unique_network_flow_endpoints PRIVATE rclcpp::rclcpp ${std_msgs_TARGETS})
3333

3434
add_executable(subscriber_not_composable not_composable.cpp)
35-
ament_target_dependencies(subscriber_not_composable rclcpp std_msgs)
35+
target_link_libraries(subscriber_not_composable PRIVATE rclcpp::rclcpp ${std_msgs_TARGETS})
3636

3737
add_executable(subscriber_content_filtering content_filtering.cpp)
38-
ament_target_dependencies(subscriber_content_filtering rclcpp std_msgs)
38+
target_link_libraries(subscriber_content_filtering PRIVATE rclcpp::rclcpp ${std_msgs_TARGETS})
3939

4040
add_library(wait_set_subscriber_library SHARED
4141
wait_set_subscriber.cpp
4242
static_wait_set_subscriber.cpp
4343
time_triggered_wait_set_subscriber.cpp)
44-
ament_target_dependencies(wait_set_subscriber_library rclcpp rclcpp_components std_msgs)
44+
target_link_libraries(wait_set_subscriber_library PRIVATE rclcpp::rclcpp rclcpp_components::component ${std_msgs_TARGETS})
4545

4646
rclcpp_components_register_node(wait_set_subscriber_library
4747
PLUGIN "WaitSetSubscriber"

rclcpp/wait_set/CMakeLists.txt

+10-11
Original file line numberDiff line numberDiff line change
@@ -21,44 +21,43 @@ include_directories(include)
2121

2222
add_library(talker SHARED src/talker.cpp)
2323
target_compile_definitions(talker PRIVATE WAIT_SET_DLL)
24-
ament_target_dependencies(talker rclcpp rclcpp_components std_msgs)
24+
target_link_libraries(talker PUBLIC rclcpp::rclcpp rclcpp_components::component ${std_msgs_TARGETS})
2525
rclcpp_components_register_node(
2626
talker
2727
PLUGIN "Talker"
2828
EXECUTABLE wait_set_talker)
2929

3030
add_library(listener SHARED src/listener.cpp)
3131
target_compile_definitions(listener PRIVATE WAIT_SET_DLL)
32-
ament_target_dependencies(listener rclcpp rclcpp_components std_msgs)
32+
target_link_libraries(listener PUBLIC rclcpp::rclcpp rclcpp_components::component ${std_msgs_TARGETS})
3333
rclcpp_components_register_node(
3434
listener
3535
PLUGIN "Listener"
3636
EXECUTABLE wait_set_listener)
3737

3838
add_executable(wait_set src/wait_set.cpp)
39-
ament_target_dependencies(wait_set example_interfaces rclcpp std_msgs)
39+
target_link_libraries(wait_set PRIVATE ${example_interfaces_TARGETS} rclcpp::rclcpp ${std_msgs_TARGETS})
4040

4141
add_executable(static_wait_set src/static_wait_set.cpp)
42-
ament_target_dependencies(static_wait_set rclcpp std_msgs)
42+
target_link_libraries(static_wait_set PRIVATE rclcpp::rclcpp ${std_msgs_TARGETS})
4343

4444
add_executable(thread_safe_wait_set src/thread_safe_wait_set.cpp)
45-
ament_target_dependencies(thread_safe_wait_set example_interfaces rclcpp std_msgs)
45+
target_link_libraries(thread_safe_wait_set PRIVATE ${example_interfaces_TARGETS} rclcpp::rclcpp ${std_msgs_TARGETS})
4646

4747
add_executable(wait_set_topics_and_timer src/wait_set_topics_and_timer.cpp)
48-
ament_target_dependencies(wait_set_topics_and_timer rclcpp std_msgs)
48+
target_link_libraries(wait_set_topics_and_timer PRIVATE rclcpp::rclcpp ${std_msgs_TARGETS})
4949

5050
add_executable(wait_set_random_order src/wait_set_random_order.cpp)
51-
ament_target_dependencies(wait_set_random_order rclcpp std_msgs)
51+
target_link_libraries(wait_set_random_order PRIVATE rclcpp::rclcpp ${std_msgs_TARGETS})
5252

5353
add_executable(executor_random_order src/executor_random_order.cpp)
54-
ament_target_dependencies(executor_random_order rclcpp std_msgs)
54+
target_link_libraries(executor_random_order PRIVATE rclcpp::rclcpp ${std_msgs_TARGETS})
5555

5656
add_executable(wait_set_topics_with_different_rates src/wait_set_topics_with_different_rates.cpp)
57-
ament_target_dependencies(wait_set_topics_with_different_rates rclcpp std_msgs)
57+
target_link_libraries(wait_set_topics_with_different_rates PRIVATE rclcpp::rclcpp ${std_msgs_TARGETS})
5858

5959
add_executable(wait_set_composed src/wait_set_composed.cpp)
60-
target_link_libraries(wait_set_composed talker listener)
61-
ament_target_dependencies(wait_set_composed rclcpp)
60+
target_link_libraries(wait_set_composed PRIVATE talker listener rclcpp::rclcpp)
6261

6362
install(TARGETS
6463
talker

0 commit comments

Comments
 (0)