From 971a6ae316e6565e00ed5bc2d0a7f7aae03bf617 Mon Sep 17 00:00:00 2001 From: Chris Lalancette Date: Mon, 27 Nov 2023 15:15:10 +0000 Subject: [PATCH] Switch to target_link_libraries everywhere. There is no need to use ament_target_dependencies. Signed-off-by: Chris Lalancette --- mcap_vendor/CMakeLists.txt | 2 +- rosbag2_cpp/CMakeLists.txt | 14 ++-- rosbag2_py/CMakeLists.txt | 4 +- rosbag2_transport/CMakeLists.txt | 81 +++++++------------ .../cmake/rosbag2_transport_add_gmock.cmake | 5 +- 5 files changed, 41 insertions(+), 65 deletions(-) diff --git a/mcap_vendor/CMakeLists.txt b/mcap_vendor/CMakeLists.txt index 862d7d61b6..72aef6efd0 100644 --- a/mcap_vendor/CMakeLists.txt +++ b/mcap_vendor/CMakeLists.txt @@ -61,7 +61,7 @@ macro(build_mcap_vendor) "$" "$" ) - ament_target_dependencies(mcap zstd) + target_link_libraries(mcap zstd::zstd) install( FILES ${_mcap_installed_headers} diff --git a/rosbag2_cpp/CMakeLists.txt b/rosbag2_cpp/CMakeLists.txt index 8d61f3af6d..9800a63cf8 100644 --- a/rosbag2_cpp/CMakeLists.txt +++ b/rosbag2_cpp/CMakeLists.txt @@ -170,22 +170,24 @@ if(BUILD_TESTING) test/rosbag2_cpp/test_info.cpp WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) if(TARGET test_info) - target_link_libraries(test_info ${PROJECT_NAME}) - ament_target_dependencies(test_info rosbag2_test_common test_msgs) + target_link_libraries(test_info ${PROJECT_NAME} rosbag2_test_common::rosbag2_test_common ${test_msgs_TARGETS}) endif() ament_add_gmock(test_sequential_reader test/rosbag2_cpp/test_sequential_reader.cpp test/rosbag2_cpp/fake_data.cpp) if(TARGET test_sequential_reader) - ament_target_dependencies(test_sequential_reader rosbag2_storage rosbag2_test_common test_msgs) - target_link_libraries(test_sequential_reader ${PROJECT_NAME}) + target_link_libraries(test_sequential_reader + ${PROJECT_NAME} + rosbag2_storage::rosbag2_storage + rosbag2_test_common::rosbag2_test_common + ${test_msgs_TARGETS} + ) endif() ament_add_gmock(test_storage_without_metadata_file test/rosbag2_cpp/test_storage_without_metadata_file.cpp) if(TARGET test_storage_without_metadata_file) - ament_target_dependencies(test_storage_without_metadata_file rosbag2_storage) - target_link_libraries(test_storage_without_metadata_file ${PROJECT_NAME}) + target_link_libraries(test_storage_without_metadata_file ${PROJECT_NAME} rosbag2_storage::rosbag2_storage) endif() ament_add_gmock(test_local_message_definition_source diff --git a/rosbag2_py/CMakeLists.txt b/rosbag2_py/CMakeLists.txt index 0b71864e54..1f90a8a171 100644 --- a/rosbag2_py/CMakeLists.txt +++ b/rosbag2_py/CMakeLists.txt @@ -44,8 +44,8 @@ ament_python_install_package(${PROJECT_NAME}) pybind11_add_module(_compression_options SHARED src/rosbag2_py/_compression_options.cpp ) -ament_target_dependencies(_compression_options PUBLIC - "rosbag2_compression" +target_link_libraries(_compression_options PUBLIC + rosbag2_compression::rosbag2_compression ) pybind11_add_module(_reader SHARED diff --git a/rosbag2_transport/CMakeLists.txt b/rosbag2_transport/CMakeLists.txt index d3f66e6c80..322f825760 100644 --- a/rosbag2_transport/CMakeLists.txt +++ b/rosbag2_transport/CMakeLists.txt @@ -106,129 +106,106 @@ function(create_tests_for_rmw_implementation) rosbag2_transport_add_gmock(test_play test/rosbag2_transport/test_play.cpp - LINK_LIBS rosbag2_transport - AMENT_DEPS test_msgs rosbag2_test_common + LINK_LIBS rosbag2_transport ${test_msgs_TARGETS} rosbag2_test_common::rosbag2_test_common ${SKIP_TEST}) rosbag2_transport_add_gmock(test_play_loop test/rosbag2_transport/test_play_loop.cpp - LINK_LIBS rosbag2_transport - AMENT_DEPS test_msgs rosbag2_test_common + LINK_LIBS rosbag2_transport ${test_msgs_TARGETS} rosbag2_test_common::rosbag2_test_common ${SKIP_TEST}) rosbag2_transport_add_gmock(test_play_publish_clock test/rosbag2_transport/test_play_publish_clock.cpp - LINK_LIBS rosbag2_transport - AMENT_DEPS test_msgs rosbag2_test_common + LINK_LIBS rosbag2_transport ${test_msgs_TARGETS} rosbag2_test_common::rosbag2_test_common ${SKIP_TEST}) rosbag2_transport_add_gmock(test_play_timing test/rosbag2_transport/test_play_timing.cpp - LINK_LIBS rosbag2_transport - AMENT_DEPS test_msgs rosbag2_test_common) + LINK_LIBS rosbag2_transport ${test_msgs_TARGETS} rosbag2_test_common::rosbag2_test_common) rosbag2_transport_add_gmock(test_play_callbacks test/rosbag2_transport/test_play_callbacks.cpp - LINK_LIBS rosbag2_transport - AMENT_DEPS test_msgs rosbag2_test_common) + LINK_LIBS rosbag2_transport ${test_msgs_TARGETS} rosbag2_test_common::rosbag2_test_common) rosbag2_transport_add_gmock(test_player_stop test/rosbag2_transport/test_player_stop.cpp - LINK_LIBS rosbag2_transport - AMENT_DEPS test_msgs rosbag2_test_common) + LINK_LIBS rosbag2_transport ${test_msgs_TARGETS} rosbag2_test_common::rosbag2_test_common) rosbag2_transport_add_gmock(test_play_seek test/rosbag2_transport/test_play_seek.cpp - LINK_LIBS rosbag2_transport - AMENT_DEPS test_msgs rosbag2_test_common) + LINK_LIBS rosbag2_transport ${test_msgs_TARGETS} rosbag2_test_common::rosbag2_test_common) rosbag2_transport_add_gmock(test_play_services test/rosbag2_transport/test_play_services.cpp - LINK_LIBS rosbag2_transport - AMENT_DEPS test_msgs rosbag2_test_common) + LINK_LIBS rosbag2_transport ${test_msgs_TARGETS} rosbag2_test_common::rosbag2_test_common) rosbag2_transport_add_gmock(test_play_topic_remap test/rosbag2_transport/test_play_topic_remap.cpp - LINK_LIBS rosbag2_transport - AMENT_DEPS test_msgs rosbag2_test_common + LINK_LIBS rosbag2_transport ${test_msgs_TARGETS} rosbag2_test_common::rosbag2_test_common ${SKIP_TEST}) rosbag2_transport_add_gmock(test_play_duration - test/rosbag2_transport/test_play_duration.cpp - INCLUDE_DIRS $ - LINK_LIBS rosbag2_transport - AMENT_DEPS test_msgs rosbag2_test_common) + test/rosbag2_transport/test_play_duration.cpp + INCLUDE_DIRS $ + LINK_LIBS rosbag2_transport ${test_msgs_TARGETS} rosbag2_test_common::rosbag2_test_common) rosbag2_transport_add_gmock(test_play_next - test/rosbag2_transport/test_play_next.cpp - INCLUDE_DIRS $ - LINK_LIBS rosbag2_transport - AMENT_DEPS test_msgs rosbag2_test_common) + test/rosbag2_transport/test_play_next.cpp + INCLUDE_DIRS $ + LINK_LIBS rosbag2_transport ${test_msgs_TARGETS} rosbag2_test_common::rosbag2_test_common) rosbag2_transport_add_gmock(test_play_until - test/rosbag2_transport/test_play_until.cpp - INCLUDE_DIRS $ - LINK_LIBS rosbag2_transport - AMENT_DEPS test_msgs rosbag2_test_common) + test/rosbag2_transport/test_play_until.cpp + INCLUDE_DIRS $ + LINK_LIBS rosbag2_transport ${test_msgs_TARGETS} rosbag2_test_common::rosbag2_test_common) rosbag2_transport_add_gmock(test_burst test/rosbag2_transport/test_burst.cpp INCLUDE_DIRS $ - LINK_LIBS rosbag2_transport - AMENT_DEPS test_msgs rosbag2_test_common) + LINK_LIBS rosbag2_transport ${test_msgs_TARGETS} rosbag2_test_common::rosbag2_test_common) rosbag2_transport_add_gmock(test_record test/rosbag2_transport/test_record.cpp INCLUDE_DIRS $ - LINK_LIBS rosbag2_transport - AMENT_DEPS test_msgs rosbag2_test_common + LINK_LIBS rosbag2_transport ${test_msgs_TARGETS} rosbag2_test_common::rosbag2_test_common ${SKIP_TEST}) rosbag2_transport_add_gmock(test_record_all test/rosbag2_transport/test_record_all.cpp - LINK_LIBS rosbag2_transport - AMENT_DEPS test_msgs rosbag2_test_common) + LINK_LIBS rosbag2_transport ${test_msgs_TARGETS} rosbag2_test_common::rosbag2_test_common) rosbag2_transport_add_gmock(test_record_all_ignore_leaf_topics test/rosbag2_transport/test_record_all_ignore_leaf_topics.cpp - LINK_LIBS rosbag2_transport - AMENT_DEPS test_msgs rosbag2_test_common) + LINK_LIBS rosbag2_transport ${test_msgs_TARGETS} rosbag2_test_common::rosbag2_test_common) rosbag2_transport_add_gmock(test_record_all_include_unpublished_topics test/rosbag2_transport/test_record_all_include_unpublished_topics.cpp - LINK_LIBS rosbag2_transport - AMENT_DEPS test_msgs rosbag2_test_common) + LINK_LIBS rosbag2_transport ${test_msgs_TARGETS} rosbag2_test_common::rosbag2_test_common) rosbag2_transport_add_gmock(test_record_all_no_discovery test/rosbag2_transport/test_record_all_no_discovery.cpp - LINK_LIBS rosbag2_transport - AMENT_DEPS test_msgs rosbag2_test_common) + LINK_LIBS rosbag2_transport ${test_msgs_TARGETS} rosbag2_test_common::rosbag2_test_common) rosbag2_transport_add_gmock(test_record_all_use_sim_time test/rosbag2_transport/test_record_all_use_sim_time.cpp - LINK_LIBS rosbag2_transport - AMENT_DEPS test_msgs rosbag2_test_common) + LINK_LIBS rosbag2_transport ${test_msgs_TARGETS} rosbag2_test_common::rosbag2_test_common) rosbag2_transport_add_gmock(test_keyboard_controls test/rosbag2_transport/test_keyboard_controls.cpp - LINK_LIBS rosbag2_transport - AMENT_DEPS test_msgs rosbag2_test_common) + LINK_LIBS rosbag2_transport ${test_msgs_TARGETS} rosbag2_test_common::rosbag2_test_common) rosbag2_transport_add_gmock(test_record_regex test/rosbag2_transport/test_record_regex.cpp - LINK_LIBS rosbag2_transport - AMENT_DEPS test_msgs rosbag2_test_common + LINK_LIBS rosbag2_transport ${test_msgs_TARGETS} rosbag2_test_common::rosbag2_test_common ${SKIP_TEST}) rosbag2_transport_add_gmock(test_record_services test/rosbag2_transport/test_record_services.cpp - LINK_LIBS rosbag2_transport - AMENT_DEPS test_msgs rosbag2_test_common) + LINK_LIBS rosbag2_transport ${test_msgs_TARGETS} rosbag2_test_common::rosbag2_test_common) rosbag2_transport_add_gmock(test_component_parameters test/rosbag2_transport/test_composable_recorder.cpp - LINK_LIBS rosbag2_transport - AMENT_DEPS test_msgs rosbag2_test_common) + LINK_LIBS rosbag2_transport ${test_msgs_TARGETS} rosbag2_test_common::rosbag2_test_common) if(${rmw_implementation} MATCHES "rmw_cyclonedds(.*)") ament_add_test_label(test_play_services__rmw_cyclonedds_cpp xfail) diff --git a/rosbag2_transport/cmake/rosbag2_transport_add_gmock.cmake b/rosbag2_transport/cmake/rosbag2_transport_add_gmock.cmake index bbaba9f126..f9b61650ab 100644 --- a/rosbag2_transport/cmake/rosbag2_transport_add_gmock.cmake +++ b/rosbag2_transport/cmake/rosbag2_transport_add_gmock.cmake @@ -28,8 +28,6 @@ # :type GENERATE_DEFAULT: option # :param LINK_LIBS: libraries to link to the test executable # :type LINK_LIBS: list of strings -# :param AMENT_DEPS: ament dependencies to declare for the test executable -# :type AMENT_DEPS: list of strings # :param INCLUDE_DIRS: extra include directories to use for building the test # :type INCLUDE_DIRS: list of strings # @@ -37,7 +35,7 @@ function(rosbag2_transport_add_gmock target_base) cmake_parse_arguments(ARG "SKIP_TEST" "" - "LINK_LIBS;AMENT_DEPS;INCLUDE_DIRS" + "LINK_LIBS;INCLUDE_DIRS" ${ARGN}) if(NOT ARG_UNPARSED_ARGUMENTS) message(FATAL_ERROR "rosbag2_transport_add_gmock() must be invoked with " @@ -57,7 +55,6 @@ function(rosbag2_transport_add_gmock target_base) WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} ${SKIP_TEST}) if(TARGET ${target_name}) - ament_target_dependencies(${target_name} ${ARG_AMENT_DEPS}) target_link_libraries(${target_name} ${ARG_LINK_LIBS}) target_include_directories(${target_name} PUBLIC ${ARG_INCLUDE_DIRS}) endif()