Skip to content

Commit

Permalink
Remove most remaining uses of ament_target_dependencies. (#1102)
Browse files Browse the repository at this point in the history
Instead, switch to using target_link_libraries everywhere
we can.  We can't do it for the rmw_implementation substitution,
since the libraries aren't always called the same thing
as the rmw_implementation.

Signed-off-by: Chris Lalancette <[email protected]>
  • Loading branch information
clalancette committed Sep 28, 2023
1 parent c65b517 commit 9a05fa6
Show file tree
Hide file tree
Showing 4 changed files with 103 additions and 138 deletions.
115 changes: 49 additions & 66 deletions rcl/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ function(test_target_function)
SRCS rcl/test_client.cpp
ENV ${rmw_implementation_env_var}
APPEND_LIBRARY_DIRS ${extra_lib_dirs}
LIBRARIES ${PROJECT_NAME}
AMENT_DEPENDENCIES ${rmw_implementation} "osrf_testing_tools_cpp" "test_msgs"
LIBRARIES ${PROJECT_NAME} osrf_testing_tools_cpp::memory_tools ${test_msgs_TARGETS}
AMENT_DEPENDENCIES ${rmw_implementation}
)

rcl_add_custom_gtest(test_timer${target_suffix}
Expand All @@ -81,41 +81,41 @@ function(test_target_function)
SRCS rcl/test_get_node_names.cpp
ENV ${rmw_implementation_env_var}
APPEND_LIBRARY_DIRS ${extra_lib_dirs}
LIBRARIES ${PROJECT_NAME}
AMENT_DEPENDENCIES ${rmw_implementation} "osrf_testing_tools_cpp"
LIBRARIES ${PROJECT_NAME} osrf_testing_tools_cpp::memory_tools
AMENT_DEPENDENCIES ${rmw_implementation}
)

rcl_add_custom_gtest(test_graph${target_suffix}
SRCS rcl/test_graph.cpp
ENV ${rmw_implementation_env_var}
APPEND_LIBRARY_DIRS ${extra_lib_dirs}
LIBRARIES ${PROJECT_NAME}
AMENT_DEPENDENCIES ${rmw_implementation} "osrf_testing_tools_cpp" "test_msgs"
LIBRARIES ${PROJECT_NAME} osrf_testing_tools_cpp::memory_tools ${test_msgs_TARGETS}
AMENT_DEPENDENCIES ${rmw_implementation}
TIMEOUT 120
)

rcl_add_custom_gtest(test_info_by_topic${target_suffix}
SRCS rcl/test_info_by_topic.cpp
ENV ${rmw_implementation_env_var}
APPEND_LIBRARY_DIRS ${extra_lib_dirs}
LIBRARIES ${PROJECT_NAME} wait_for_entity_helpers
AMENT_DEPENDENCIES ${rmw_implementation} "osrf_testing_tools_cpp" "test_msgs"
LIBRARIES ${PROJECT_NAME} wait_for_entity_helpers osrf_testing_tools_cpp::memory_tools ${test_msgs_TARGETS}
AMENT_DEPENDENCIES ${rmw_implementation}
)

rcl_add_custom_gtest(test_count_matched${target_suffix}
SRCS rcl/test_count_matched.cpp
ENV ${rmw_implementation_env_var}
APPEND_LIBRARY_DIRS ${extra_lib_dirs}
LIBRARIES ${PROJECT_NAME}
AMENT_DEPENDENCIES ${rmw_implementation} "osrf_testing_tools_cpp" "test_msgs"
LIBRARIES ${PROJECT_NAME} osrf_testing_tools_cpp::memory_tools ${test_msgs_TARGETS}
AMENT_DEPENDENCIES ${rmw_implementation}
)

rcl_add_custom_gtest(test_get_actual_qos${target_suffix}
SRCS rcl/test_get_actual_qos.cpp
ENV ${rmw_implementation_env_var}
APPEND_LIBRARY_DIRS ${extra_lib_dirs}
LIBRARIES ${PROJECT_NAME}
AMENT_DEPENDENCIES ${rmw_implementation} "test_msgs" "osrf_testing_tools_cpp"
LIBRARIES ${PROJECT_NAME} osrf_testing_tools_cpp::memory_tools ${test_msgs_TARGETS}
AMENT_DEPENDENCIES ${rmw_implementation}
)

rcl_add_custom_gtest(test_init${target_suffix}
Expand All @@ -141,7 +141,7 @@ function(test_target_function)
ENV ${rmw_implementation_env_var} ${memory_tools_ld_preload_env_var} ${gtest_filter_env_var}
APPEND_LIBRARY_DIRS ${extra_lib_dirs}
LIBRARIES ${PROJECT_NAME} mimick osrf_testing_tools_cpp::memory_tools
AMENT_DEPENDENCIES ${rmw_implementation} "osrf_testing_tools_cpp"
AMENT_DEPENDENCIES ${rmw_implementation}
TIMEOUT 240 # Large timeout to wait for fault injection tests
)

Expand All @@ -150,66 +150,59 @@ function(test_target_function)
ENV ${rmw_implementation_env_var}
APPEND_LIBRARY_DIRS ${extra_lib_dirs}
INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/../src/rcl/
LIBRARIES ${PROJECT_NAME}
AMENT_DEPENDENCIES "osrf_testing_tools_cpp"
LIBRARIES ${PROJECT_NAME} osrf_testing_tools_cpp::memory_tools
)

rcl_add_custom_gtest(test_remap_integration${target_suffix}
SRCS rcl/test_remap_integration.cpp
TIMEOUT 200
ENV ${rmw_implementation_env_var}
APPEND_LIBRARY_DIRS ${extra_lib_dirs}
LIBRARIES ${PROJECT_NAME}
AMENT_DEPENDENCIES "osrf_testing_tools_cpp" "test_msgs"
LIBRARIES ${PROJECT_NAME} osrf_testing_tools_cpp::memory_tools ${test_msgs_TARGETS}
)

rcl_add_custom_gtest(test_guard_condition${target_suffix}
SRCS rcl/test_guard_condition.cpp
ENV ${rmw_implementation_env_var} ${memory_tools_ld_preload_env_var}
APPEND_LIBRARY_DIRS ${extra_lib_dirs}
LIBRARIES ${PROJECT_NAME} mimick osrf_testing_tools_cpp::memory_tools
AMENT_DEPENDENCIES ${rmw_implementation} "osrf_testing_tools_cpp"
AMENT_DEPENDENCIES ${rmw_implementation}
)

rcl_add_custom_gtest(test_publisher${target_suffix}
SRCS rcl/test_publisher.cpp
ENV ${rmw_implementation_env_var}
APPEND_LIBRARY_DIRS ${extra_lib_dirs}
INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/../src/rcl/
LIBRARIES ${PROJECT_NAME} mimick
AMENT_DEPENDENCIES ${rmw_implementation} "osrf_testing_tools_cpp" "test_msgs"
LIBRARIES ${PROJECT_NAME} mimick osrf_testing_tools_cpp::memory_tools ${test_msgs_TARGETS}
AMENT_DEPENDENCIES ${rmw_implementation}
)

rcl_add_custom_gtest(test_publisher_wait_all_ack${target_suffix}
SRCS rcl/test_publisher_wait_all_ack.cpp
ENV ${rmw_implementation_env_var}
APPEND_LIBRARY_DIRS ${extra_lib_dirs}
INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/../src/rcl/
LIBRARIES ${PROJECT_NAME} mimick wait_for_entity_helpers
LIBRARIES ${PROJECT_NAME} mimick wait_for_entity_helpers osrf_testing_tools_cpp::memory_tools rcutils::rcutils
rosidl_runtime_c::rosidl_runtime_c ${test_msgs_TARGETS}
AMENT_DEPENDENCIES ${rmw_implementation}
"osrf_testing_tools_cpp"
"rcutils"
"rosidl_runtime_c"
"test_msgs"
)

rcl_add_custom_gtest(test_service${target_suffix}
SRCS rcl/test_service.cpp
ENV ${rmw_implementation_env_var}
APPEND_LIBRARY_DIRS ${extra_lib_dirs}
LIBRARIES ${PROJECT_NAME} mimick wait_for_entity_helpers
AMENT_DEPENDENCIES ${rmw_implementation} "osrf_testing_tools_cpp" "test_msgs"
LIBRARIES ${PROJECT_NAME} mimick wait_for_entity_helpers osrf_testing_tools_cpp::memory_tools ${test_msgs_TARGETS}
AMENT_DEPENDENCIES ${rmw_implementation}
)

rcl_add_custom_gtest(test_subscription${target_suffix}
SRCS rcl/test_subscription.cpp
ENV ${rmw_implementation_env_var}
APPEND_LIBRARY_DIRS ${extra_lib_dirs}
LIBRARIES ${PROJECT_NAME} mimick wait_for_entity_helpers
LIBRARIES ${PROJECT_NAME} mimick wait_for_entity_helpers osrf_testing_tools_cpp::memory_tools rosidl_runtime_cpp::rosidl_runtime_cpp
${test_msgs_TARGETS}
AMENT_DEPENDENCIES ${rmw_implementation}
"osrf_testing_tools_cpp"
"rosidl_runtime_cpp"
"test_msgs"
TIMEOUT 120
)
# TODO(asorbini) Enable message timestamp tests for rmw_connextdds on Windows
Expand Down Expand Up @@ -239,32 +232,32 @@ function(test_target_function)
ENV ${rmw_implementation_env_var}
APPEND_LIBRARY_DIRS ${extra_lib_dirs}
INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/../src/rcl/
LIBRARIES ${PROJECT_NAME}
AMENT_DEPENDENCIES ${rmw_implementation} "osrf_testing_tools_cpp" "test_msgs"
LIBRARIES ${PROJECT_NAME} osrf_testing_tools_cpp::memory_tools ${test_msgs_TARGETS}
AMENT_DEPENDENCIES ${rmw_implementation}
)

rcl_add_custom_gtest(test_wait${target_suffix}
SRCS rcl/test_wait.cpp
ENV ${rmw_implementation_env_var}
APPEND_LIBRARY_DIRS ${extra_lib_dirs}
LIBRARIES ${PROJECT_NAME} mimick
AMENT_DEPENDENCIES ${rmw_implementation} "osrf_testing_tools_cpp"
LIBRARIES ${PROJECT_NAME} mimick osrf_testing_tools_cpp::memory_tools
AMENT_DEPENDENCIES ${rmw_implementation}
)

rcl_add_custom_gtest(test_logging_rosout${target_suffix}
SRCS rcl/test_logging_rosout.cpp
ENV ${rmw_implementation_env_var}
APPEND_LIBRARY_DIRS ${extra_lib_dirs}
LIBRARIES ${PROJECT_NAME}
AMENT_DEPENDENCIES ${rmw_implementation} "osrf_testing_tools_cpp" "rcl_interfaces"
LIBRARIES ${PROJECT_NAME} osrf_testing_tools_cpp::memory_tools ${rcl_interfaces_TARGETS}
AMENT_DEPENDENCIES ${rmw_implementation}
)

rcl_add_custom_gtest(test_namespace${target_suffix}
SRCS rcl/test_namespace.cpp
ENV ${rmw_implementation_env_var}
APPEND_LIBRARY_DIRS ${extra_lib_dirs}
LIBRARIES ${PROJECT_NAME}
AMENT_DEPENDENCIES ${rmw_implementation} "osrf_testing_tools_cpp" "test_msgs"
LIBRARIES ${PROJECT_NAME} osrf_testing_tools_cpp::memory_tools ${test_msgs_TARGETS}
AMENT_DEPENDENCIES ${rmw_implementation}
)

rcl_add_custom_gtest(test_rmw_impl_id_check_func${target_suffix}
Expand All @@ -280,57 +273,54 @@ function(test_target_function)
ENV ${rmw_implementation_env_var}
APPEND_LIBRARY_DIRS ${extra_lib_dirs}
INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/../src/rcl/
LIBRARIES ${PROJECT_NAME} mimick
AMENT_DEPENDENCIES ${rmw_implementation} "osrf_testing_tools_cpp" "test_msgs"
LIBRARIES ${PROJECT_NAME} mimick osrf_testing_tools_cpp::memory_tools ${test_msgs_TARGETS}
AMENT_DEPENDENCIES ${rmw_implementation}
)

rcl_add_custom_gtest(test_service_event_publisher${target_suffix}
SRCS rcl/test_service_event_publisher.cpp
ENV ${rmw_implementation_env_var}
APPEND_LIBRARY_DIRS ${extra_lib_dirs}
INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/../src/rcl/
LIBRARIES ${PROJECT_NAME} mimick wait_for_entity_helpers
AMENT_DEPENDENCIES ${rmw_implementation} "osrf_testing_tools_cpp" "test_msgs"
LIBRARIES ${PROJECT_NAME} mimick wait_for_entity_helpers osrf_testing_tools_cpp::memory_tools ${test_msgs_TARGETS}
AMENT_DEPENDENCIES ${rmw_implementation}
)

rcl_add_custom_gtest(test_type_description_conversions${target_suffix}
SRCS rcl/test_type_description_conversions.cpp
APPEND_LIBRARY_DIRS ${extra_lib_dirs}
INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/../src/rcl/
LIBRARIES ${PROJECT_NAME}
AMENT_DEPENDENCIES "test_msgs"
LIBRARIES ${PROJECT_NAME} ${test_msgs_TARGETS}
)

rcl_add_custom_gtest(test_node_type_cache${target_suffix}
SRCS rcl/test_node_type_cache.cpp
ENV ${rmw_implementation_env_var}
APPEND_LIBRARY_DIRS ${extra_lib_dirs}
INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/../src/rcl/
LIBRARIES ${PROJECT_NAME} mimick
AMENT_DEPENDENCIES ${rmw_implementation} "osrf_testing_tools_cpp" "test_msgs"
LIBRARIES ${PROJECT_NAME} mimick osrf_testing_tools_cpp::memory_tools ${test_msgs_TARGETS}
AMENT_DEPENDENCIES ${rmw_implementation}
)

rcl_add_custom_gtest(test_get_type_description_service${target_suffix}
SRCS rcl/test_get_type_description_service.cpp
ENV ${rmw_implementation_env_var}
APPEND_LIBRARY_DIRS ${extra_lib_dirs}
INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/../src/rcl/
LIBRARIES ${PROJECT_NAME} mimick wait_for_entity_helpers
AMENT_DEPENDENCIES ${rmw_implementation} "osrf_testing_tools_cpp" "type_description_interfaces"
LIBRARIES ${PROJECT_NAME} mimick wait_for_entity_helpers osrf_testing_tools_cpp::memory_tools ${type_description_interfaces_TARGETS}
AMENT_DEPENDENCIES ${rmw_implementation}
)

# Launch tests

rcl_add_custom_executable(service_fixture${target_suffix}
SRCS rcl/service_fixture.cpp
LIBRARIES ${PROJECT_NAME} wait_for_entity_helpers
AMENT_DEPENDENCIES ${rmw_implementation} "osrf_testing_tools_cpp" "test_msgs"
LIBRARIES ${PROJECT_NAME} wait_for_entity_helpers osrf_testing_tools_cpp::memory_tools ${test_msgs_TARGETS} rcutils::rcutils
)

rcl_add_custom_executable(client_fixture${target_suffix}
SRCS rcl/client_fixture.cpp
LIBRARIES ${PROJECT_NAME} wait_for_entity_helpers
AMENT_DEPENDENCIES ${rmw_implementation} "osrf_testing_tools_cpp" "test_msgs"
LIBRARIES ${PROJECT_NAME} wait_for_entity_helpers osrf_testing_tools_cpp::memory_tools ${test_msgs_TARGETS}
)

rcl_add_custom_launch_test(test_services
Expand Down Expand Up @@ -392,7 +382,6 @@ rcl_add_custom_gtest(test_arguments
APPEND_LIBRARY_DIRS ${extra_lib_dirs}
INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/../src/rcl/
LIBRARIES ${PROJECT_NAME} osrf_testing_tools_cpp::memory_tools
AMENT_DEPENDENCIES "osrf_testing_tools_cpp"
)

rcl_add_custom_gtest(test_time
Expand All @@ -411,8 +400,7 @@ rcl_add_custom_gtest(test_lexer
rcl_add_custom_gtest(test_lexer_lookahead
SRCS rcl/test_lexer_lookahead.cpp
APPEND_LIBRARY_DIRS ${extra_lib_dirs}
LIBRARIES ${PROJECT_NAME}
AMENT_DEPENDENCIES "osrf_testing_tools_cpp"
LIBRARIES ${PROJECT_NAME} osrf_testing_tools_cpp::memory_tools
)

rcl_add_custom_gtest(test_validate_enclave_name
Expand All @@ -424,8 +412,7 @@ rcl_add_custom_gtest(test_validate_enclave_name
rcl_add_custom_gtest(test_discovery_options
SRCS rcl/test_discovery_options.cpp
APPEND_LIBRARY_DIRS ${extra_lib_dirs}
LIBRARIES ${PROJECT_NAME}
AMENT_DEPENDENCIES "osrf_testing_tools_cpp"
LIBRARIES ${PROJECT_NAME} osrf_testing_tools_cpp::memory_tools
)

rcl_add_custom_gtest(test_domain_id
Expand All @@ -444,8 +431,7 @@ rcl_add_custom_gtest(test_logging
SRCS rcl/test_logging.cpp
APPEND_LIBRARY_DIRS ${extra_lib_dirs}
LIBRARIES ${PROJECT_NAME} mimick ${rcl_interfaces_TARGETS}
rcl_logging_interface::rcl_logging_interface ${RCL_LOGGING_IMPL}::${RCL_LOGGING_IMPL}
AMENT_DEPENDENCIES "osrf_testing_tools_cpp"
rcl_logging_interface::rcl_logging_interface ${RCL_LOGGING_IMPL}::${RCL_LOGGING_IMPL} osrf_testing_tools_cpp::memory_tools
)

rcl_add_custom_gtest(test_validate_topic_name
Expand All @@ -463,8 +449,7 @@ rcl_add_custom_gtest(test_expand_topic_name
rcl_add_custom_gtest(test_security
SRCS rcl/test_security.cpp
APPEND_LIBRARY_DIRS ${extra_lib_dirs}
LIBRARIES ${PROJECT_NAME} mimick
AMENT_DEPENDENCIES "osrf_testing_tools_cpp"
LIBRARIES ${PROJECT_NAME} mimick osrf_testing_tools_cpp::memory_tools
)

rcl_add_custom_gtest(test_common
Expand All @@ -477,15 +462,13 @@ rcl_add_custom_gtest(test_common
rcl_add_custom_gtest(test_log_level
SRCS rcl/test_log_level.cpp
APPEND_LIBRARY_DIRS ${extra_lib_dirs}
LIBRARIES ${PROJECT_NAME} mimick
AMENT_DEPENDENCIES "osrf_testing_tools_cpp"
LIBRARIES ${PROJECT_NAME} mimick osrf_testing_tools_cpp::memory_tools
)

rcl_add_custom_gtest(test_subscription_content_filter_options
SRCS rcl/test_subscription_content_filter_options.cpp
APPEND_LIBRARY_DIRS ${extra_lib_dirs}
LIBRARIES ${PROJECT_NAME}
AMENT_DEPENDENCIES "osrf_testing_tools_cpp" "test_msgs"
LIBRARIES ${PROJECT_NAME} osrf_testing_tools_cpp::memory_tools ${test_msgs_TARGETS}
)

rcl_add_custom_gtest(test_type_hash
Expand Down
9 changes: 1 addition & 8 deletions rcl/test/cmake/rcl_add_custom_executable.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ macro(rcl_add_custom_executable target)
cmake_parse_arguments(_ARG
"TRACE"
""
"SRCS;INCLUDE_DIRS;LIBRARIES;AMENT_DEPENDENCIES"
"SRCS;INCLUDE_DIRS;LIBRARIES"
${ARGN})
if(_ARG_UNPARSED_ARGUMENTS)
message(FATAL_ERROR
Expand All @@ -48,13 +48,6 @@ macro(rcl_add_custom_executable target)
endif()
target_link_libraries(${target} ${_ARG_LIBRARIES})
endif()
# Add extra ament dependencies, if any.
if(_ARG_AMENT_DEPENDENCIES)
if(_ARG_TRACE)
message(STATUS " rcl_add_custom_executable() AMENT_DEPENDENCIES: ${_ARG_AMENT_DEPENDENCIES}")
endif()
ament_target_dependencies(${target} ${_ARG_AMENT_DEPENDENCIES})
endif()
target_compile_definitions(${target}
PUBLIC "RMW_IMPLEMENTATION=${rmw_implementation}")
endmacro()
Loading

0 comments on commit 9a05fa6

Please sign in to comment.