Skip to content

Commit

Permalink
Switch to target_link_libraries everywhere.
Browse files Browse the repository at this point in the history
There is no need to use ament_target_dependencies.

Signed-off-by: Chris Lalancette <[email protected]>
  • Loading branch information
clalancette committed Nov 27, 2023
1 parent 9855072 commit 971a6ae
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 65 deletions.
2 changes: 1 addition & 1 deletion mcap_vendor/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ macro(build_mcap_vendor)
"$<BUILD_INTERFACE:${_mcap_include_dir}>"
"$<INSTALL_INTERFACE:include/${PROJECT_NAME}>"
)
ament_target_dependencies(mcap zstd)
target_link_libraries(mcap zstd::zstd)

install(
FILES ${_mcap_installed_headers}
Expand Down
14 changes: 8 additions & 6 deletions rosbag2_cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions rosbag2_py/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
81 changes: 29 additions & 52 deletions rosbag2_transport/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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 $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/rosbag2_transport>
LINK_LIBS rosbag2_transport
AMENT_DEPS test_msgs rosbag2_test_common)
test/rosbag2_transport/test_play_duration.cpp
INCLUDE_DIRS $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/rosbag2_transport>
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 $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/rosbag2_transport>
LINK_LIBS rosbag2_transport
AMENT_DEPS test_msgs rosbag2_test_common)
test/rosbag2_transport/test_play_next.cpp
INCLUDE_DIRS $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/rosbag2_transport>
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 $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/rosbag2_transport>
LINK_LIBS rosbag2_transport
AMENT_DEPS test_msgs rosbag2_test_common)
test/rosbag2_transport/test_play_until.cpp
INCLUDE_DIRS $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/rosbag2_transport>
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 $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/rosbag2_transport>
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 $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/rosbag2_transport>
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)
Expand Down
5 changes: 1 addition & 4 deletions rosbag2_transport/cmake/rosbag2_transport_add_gmock.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,14 @@
# :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
#
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 "
Expand All @@ -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()
Expand Down

0 comments on commit 971a6ae

Please sign in to comment.