Using ament_target_dependencies where possible (#400)

* Using ament_target_dependencies where possible

Signed-off-by: ivanpauno <ivanpauno@ekumenlabs.com>

* Modified rcl_add_custom_* to use AMENT_DEPENDENCIES where possible

Signed-off-by: ivanpauno <ivanpauno@ekumenlabs.com>

* Added again osrf_testing_tools_cpp::memory_tools library where needed.

Signed-off-by: ivanpauno <ivanpauno@ekumenlabs.com>

* Modified with PR comment, and replaced forgotten osrf_testing_tools_cpp including

Signed-off-by: ivanpauno <ivanpauno@ekumenlabs.com>
This commit is contained in:
ivanpauno 2019-03-19 09:22:16 -03:00 committed by GitHub
parent 29b0838388
commit 99630cb66d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 38 additions and 55 deletions

View file

@ -35,11 +35,10 @@ function(test_target_function)
rcl_add_custom_gtest(test_client${target_suffix} rcl_add_custom_gtest(test_client${target_suffix}
SRCS rcl/test_client.cpp SRCS rcl/test_client.cpp
INCLUDE_DIRS ${osrf_testing_tools_cpp_INCLUDE_DIRS}
ENV ${rmw_implementation_env_var} ENV ${rmw_implementation_env_var}
APPEND_LIBRARY_DIRS ${extra_lib_dirs} APPEND_LIBRARY_DIRS ${extra_lib_dirs}
LIBRARIES ${PROJECT_NAME} LIBRARIES ${PROJECT_NAME}
AMENT_DEPENDENCIES ${rmw_implementation} "test_msgs" AMENT_DEPENDENCIES ${rmw_implementation} "osrf_testing_tools_cpp" "test_msgs"
) )
rcl_add_custom_gtest(test_time${target_suffix} rcl_add_custom_gtest(test_time${target_suffix}
@ -71,11 +70,10 @@ function(test_target_function)
rcl_add_custom_gtest(test_get_node_names${target_suffix} rcl_add_custom_gtest(test_get_node_names${target_suffix}
SRCS rcl/test_get_node_names.cpp SRCS rcl/test_get_node_names.cpp
INCLUDE_DIRS ${osrf_testing_tools_cpp_INCLUDE_DIRS}
ENV ${rmw_implementation_env_var} ENV ${rmw_implementation_env_var}
APPEND_LIBRARY_DIRS ${extra_lib_dirs} APPEND_LIBRARY_DIRS ${extra_lib_dirs}
LIBRARIES ${PROJECT_NAME} LIBRARIES ${PROJECT_NAME}
AMENT_DEPENDENCIES ${rmw_implementation} AMENT_DEPENDENCIES ${rmw_implementation} "osrf_testing_tools_cpp"
) )
rcl_add_custom_gtest(test_lexer${target_suffix} rcl_add_custom_gtest(test_lexer${target_suffix}
@ -88,11 +86,10 @@ function(test_target_function)
rcl_add_custom_gtest(test_lexer_lookahead${target_suffix} rcl_add_custom_gtest(test_lexer_lookahead${target_suffix}
SRCS rcl/test_lexer_lookahead.cpp SRCS rcl/test_lexer_lookahead.cpp
INCLUDE_DIRS ${osrf_testing_tools_cpp_INCLUDE_DIRS}
ENV ${rmw_implementation_env_var} ENV ${rmw_implementation_env_var}
APPEND_LIBRARY_DIRS ${extra_lib_dirs} APPEND_LIBRARY_DIRS ${extra_lib_dirs}
LIBRARIES ${PROJECT_NAME} LIBRARIES ${PROJECT_NAME}
AMENT_DEPENDENCIES ${rmw_implementation} AMENT_DEPENDENCIES ${rmw_implementation} "osrf_testing_tools_cpp"
) )
set(AMENT_GTEST_ARGS "") set(AMENT_GTEST_ARGS "")
@ -107,21 +104,19 @@ function(test_target_function)
endif() endif()
rcl_add_custom_gtest(test_graph${target_suffix} rcl_add_custom_gtest(test_graph${target_suffix}
SRCS rcl/test_graph.cpp SRCS rcl/test_graph.cpp
INCLUDE_DIRS ${osrf_testing_tools_cpp_INCLUDE_DIRS}
ENV ${rmw_implementation_env_var} ENV ${rmw_implementation_env_var}
APPEND_LIBRARY_DIRS ${extra_lib_dirs} APPEND_LIBRARY_DIRS ${extra_lib_dirs}
LIBRARIES ${PROJECT_NAME} LIBRARIES ${PROJECT_NAME}
AMENT_DEPENDENCIES ${rmw_implementation} "test_msgs" AMENT_DEPENDENCIES ${rmw_implementation} "osrf_testing_tools_cpp" "test_msgs"
${AMENT_GTEST_ARGS} ${AMENT_GTEST_ARGS}
) )
rcl_add_custom_gtest(test_count_matched${target_suffix} rcl_add_custom_gtest(test_count_matched${target_suffix}
SRCS rcl/test_count_matched.cpp SRCS rcl/test_count_matched.cpp
INCLUDE_DIRS ${osrf_testing_tools_cpp_INCLUDE_DIRS}
ENV ${rmw_implementation_env_var} ENV ${rmw_implementation_env_var}
APPEND_LIBRARY_DIRS ${extra_lib_dirs} APPEND_LIBRARY_DIRS ${extra_lib_dirs}
LIBRARIES ${PROJECT_NAME} LIBRARIES ${PROJECT_NAME}
AMENT_DEPENDENCIES ${rmw_implementation} "test_msgs" AMENT_DEPENDENCIES ${rmw_implementation} "osrf_testing_tools_cpp" "test_msgs"
) )
rcl_add_custom_gtest(test_init${target_suffix} rcl_add_custom_gtest(test_init${target_suffix}
@ -134,11 +129,10 @@ function(test_target_function)
rcl_add_custom_gtest(test_node${target_suffix} rcl_add_custom_gtest(test_node${target_suffix}
SRCS rcl/test_node.cpp SRCS rcl/test_node.cpp
INCLUDE_DIRS ${osrf_testing_tools_cpp_INCLUDE_DIRS}
ENV ${rmw_implementation_env_var} ${memory_tools_ld_preload_env_var} ENV ${rmw_implementation_env_var} ${memory_tools_ld_preload_env_var}
APPEND_LIBRARY_DIRS ${extra_lib_dirs} APPEND_LIBRARY_DIRS ${extra_lib_dirs}
LIBRARIES ${PROJECT_NAME} osrf_testing_tools_cpp::memory_tools LIBRARIES ${PROJECT_NAME} osrf_testing_tools_cpp::memory_tools
AMENT_DEPENDENCIES ${rmw_implementation} AMENT_DEPENDENCIES ${rmw_implementation} "osrf_testing_tools_cpp"
) )
rcl_add_custom_gtest(test_arguments${target_suffix} rcl_add_custom_gtest(test_arguments${target_suffix}
@ -150,90 +144,81 @@ function(test_target_function)
rcl_add_custom_gtest(test_remap${target_suffix} rcl_add_custom_gtest(test_remap${target_suffix}
SRCS rcl/test_remap.cpp SRCS rcl/test_remap.cpp
INCLUDE_DIRS ${osrf_testing_tools_cpp_INCLUDE_DIRS}
ENV ${rmw_implementation_env_var} ENV ${rmw_implementation_env_var}
APPEND_LIBRARY_DIRS ${extra_lib_dirs} APPEND_LIBRARY_DIRS ${extra_lib_dirs}
LIBRARIES ${PROJECT_NAME} LIBRARIES ${PROJECT_NAME}
AMENT_DEPENDENCIES "osrf_testing_tools_cpp"
) )
rcl_add_custom_gtest(test_remap_integration${target_suffix} rcl_add_custom_gtest(test_remap_integration${target_suffix}
SRCS rcl/test_remap_integration.cpp SRCS rcl/test_remap_integration.cpp
INCLUDE_DIRS ${osrf_testing_tools_cpp_INCLUDE_DIRS}
TIMEOUT 200 TIMEOUT 200
ENV ${rmw_implementation_env_var} ENV ${rmw_implementation_env_var}
APPEND_LIBRARY_DIRS ${extra_lib_dirs} APPEND_LIBRARY_DIRS ${extra_lib_dirs}
LIBRARIES ${PROJECT_NAME} LIBRARIES ${PROJECT_NAME}
AMENT_DEPENDENCIES "test_msgs" AMENT_DEPENDENCIES "osrf_testing_tools_cpp" "test_msgs"
) )
rcl_add_custom_gtest(test_guard_condition${target_suffix} rcl_add_custom_gtest(test_guard_condition${target_suffix}
SRCS rcl/test_guard_condition.cpp SRCS rcl/test_guard_condition.cpp
INCLUDE_DIRS ${osrf_testing_tools_cpp_INCLUDE_DIRS}
ENV ${rmw_implementation_env_var} ${memory_tools_ld_preload_env_var} ENV ${rmw_implementation_env_var} ${memory_tools_ld_preload_env_var}
APPEND_LIBRARY_DIRS ${extra_lib_dirs} APPEND_LIBRARY_DIRS ${extra_lib_dirs}
LIBRARIES ${PROJECT_NAME} osrf_testing_tools_cpp::memory_tools LIBRARIES ${PROJECT_NAME} osrf_testing_tools_cpp::memory_tools
AMENT_DEPENDENCIES ${rmw_implementation} AMENT_DEPENDENCIES ${rmw_implementation} "osrf_testing_tools_cpp"
) )
rcl_add_custom_gtest(test_publisher${target_suffix} rcl_add_custom_gtest(test_publisher${target_suffix}
SRCS rcl/test_publisher.cpp SRCS rcl/test_publisher.cpp
INCLUDE_DIRS ${osrf_testing_tools_cpp_INCLUDE_DIRS}
ENV ${rmw_implementation_env_var} ENV ${rmw_implementation_env_var}
APPEND_LIBRARY_DIRS ${extra_lib_dirs} APPEND_LIBRARY_DIRS ${extra_lib_dirs}
LIBRARIES ${PROJECT_NAME} LIBRARIES ${PROJECT_NAME}
AMENT_DEPENDENCIES ${rmw_implementation} "test_msgs" AMENT_DEPENDENCIES ${rmw_implementation} "osrf_testing_tools_cpp" "test_msgs"
) )
rcl_add_custom_gtest(test_service${target_suffix} rcl_add_custom_gtest(test_service${target_suffix}
SRCS rcl/test_service.cpp SRCS rcl/test_service.cpp
INCLUDE_DIRS ${osrf_testing_tools_cpp_INCLUDE_DIRS}
ENV ${rmw_implementation_env_var} ENV ${rmw_implementation_env_var}
APPEND_LIBRARY_DIRS ${extra_lib_dirs} APPEND_LIBRARY_DIRS ${extra_lib_dirs}
LIBRARIES ${PROJECT_NAME} LIBRARIES ${PROJECT_NAME}
AMENT_DEPENDENCIES ${rmw_implementation} "test_msgs" AMENT_DEPENDENCIES ${rmw_implementation} "osrf_testing_tools_cpp" "test_msgs"
) )
rcl_add_custom_gtest(test_subscription${target_suffix} rcl_add_custom_gtest(test_subscription${target_suffix}
SRCS rcl/test_subscription.cpp SRCS rcl/test_subscription.cpp
INCLUDE_DIRS ${osrf_testing_tools_cpp_INCLUDE_DIRS}
ENV ${rmw_implementation_env_var} ENV ${rmw_implementation_env_var}
APPEND_LIBRARY_DIRS ${extra_lib_dirs} APPEND_LIBRARY_DIRS ${extra_lib_dirs}
LIBRARIES ${PROJECT_NAME} LIBRARIES ${PROJECT_NAME}
AMENT_DEPENDENCIES ${rmw_implementation} "test_msgs" AMENT_DEPENDENCIES ${rmw_implementation} "osrf_testing_tools_cpp" "test_msgs"
) )
rcl_add_custom_gtest(test_wait${target_suffix} rcl_add_custom_gtest(test_wait${target_suffix}
SRCS rcl/test_wait.cpp SRCS rcl/test_wait.cpp
INCLUDE_DIRS ${osrf_testing_tools_cpp_INCLUDE_DIRS}
ENV ${rmw_implementation_env_var} ENV ${rmw_implementation_env_var}
APPEND_LIBRARY_DIRS ${extra_lib_dirs} APPEND_LIBRARY_DIRS ${extra_lib_dirs}
LIBRARIES ${PROJECT_NAME} LIBRARIES ${PROJECT_NAME}
AMENT_DEPENDENCIES ${rmw_implementation} AMENT_DEPENDENCIES ${rmw_implementation} "osrf_testing_tools_cpp"
) )
rcl_add_custom_gtest(test_namespace${target_suffix} rcl_add_custom_gtest(test_namespace${target_suffix}
SRCS test_namespace.cpp SRCS test_namespace.cpp
INCLUDE_DIRS ${osrf_testing_tools_cpp_INCLUDE_DIRS}
ENV ${rmw_implementation_env_var} ENV ${rmw_implementation_env_var}
APPEND_LIBRARY_DIRS ${extra_lib_dirs} APPEND_LIBRARY_DIRS ${extra_lib_dirs}
LIBRARIES ${PROJECT_NAME} LIBRARIES ${PROJECT_NAME}
AMENT_DEPENDENCIES ${rmw_implementation} "test_msgs" AMENT_DEPENDENCIES ${rmw_implementation} "osrf_testing_tools_cpp" "test_msgs"
) )
# Launch tests # Launch tests
rcl_add_custom_executable(service_fixture${target_suffix} rcl_add_custom_executable(service_fixture${target_suffix}
SRCS rcl/service_fixture.cpp SRCS rcl/service_fixture.cpp
INCLUDE_DIRS ${osrf_testing_tools_cpp_INCLUDE_DIRS}
LIBRARIES ${PROJECT_NAME} LIBRARIES ${PROJECT_NAME}
AMENT_DEPENDENCIES ${rmw_implementation} "test_msgs" AMENT_DEPENDENCIES ${rmw_implementation} "osrf_testing_tools_cpp" "test_msgs"
) )
rcl_add_custom_executable(client_fixture${target_suffix} rcl_add_custom_executable(client_fixture${target_suffix}
SRCS rcl/client_fixture.cpp SRCS rcl/client_fixture.cpp
INCLUDE_DIRS ${osrf_testing_tools_cpp_INCLUDE_DIRS}
LIBRARIES ${PROJECT_NAME} LIBRARIES ${PROJECT_NAME}
AMENT_DEPENDENCIES ${rmw_implementation} "test_msgs" AMENT_DEPENDENCIES ${rmw_implementation} "osrf_testing_tools_cpp" "test_msgs"
) )
rcl_add_custom_launch_test(test_services rcl_add_custom_launch_test(test_services
@ -296,9 +281,9 @@ rcl_add_custom_gtest(test_expand_topic_name
rcl_add_custom_gtest(test_timer${target_suffix} rcl_add_custom_gtest(test_timer${target_suffix}
SRCS rcl/test_timer.cpp SRCS rcl/test_timer.cpp
INCLUDE_DIRS ${osrf_testing_tools_cpp_INCLUDE_DIRS}
APPEND_LIBRARY_DIRS ${extra_lib_dirs} APPEND_LIBRARY_DIRS ${extra_lib_dirs}
LIBRARIES ${PROJECT_NAME} LIBRARIES ${PROJECT_NAME}
AMENT_DEPENDENCIES "osrf_testing_tools_cpp"
) )
rcl_add_custom_gtest(test_security_directory rcl_add_custom_gtest(test_security_directory
@ -309,4 +294,4 @@ rcl_add_custom_gtest(test_security_directory
# Install test resources # Install test resources
install(DIRECTORY ${test_resources_dir_name} install(DIRECTORY ${test_resources_dir_name}
DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) DESTINATION ${CMAKE_CURRENT_BINARY_DIR})

View file

@ -87,12 +87,11 @@ if(BUILD_TESTING)
if(TARGET test_action_client) if(TARGET test_action_client)
target_include_directories(test_action_client PUBLIC target_include_directories(test_action_client PUBLIC
include include
${osrf_testing_tools_cpp_INCLUDE_DIRS}
) )
target_link_libraries(test_action_client target_link_libraries(test_action_client
${PROJECT_NAME} ${PROJECT_NAME}
) )
ament_target_dependencies(test_action_client "rcl" "test_msgs") ament_target_dependencies(test_action_client "osrf_testing_tools_cpp" "rcl" "test_msgs")
endif() endif()
# get the rmw implementations ahead of time # get the rmw implementations ahead of time
@ -118,13 +117,14 @@ if(BUILD_TESTING)
PUBLIC "RMW_IMPLEMENTATION=${rmw_implementation}") PUBLIC "RMW_IMPLEMENTATION=${rmw_implementation}")
target_include_directories(${target}${target_suffix} PUBLIC target_include_directories(${target}${target_suffix} PUBLIC
include include
${rcl_INCLUDE_DIRS}
) )
target_link_libraries(${target}${target_suffix} target_link_libraries(${target}${target_suffix}
${PROJECT_NAME} ${PROJECT_NAME}
) )
ament_target_dependencies(${target}${target_suffix} ament_target_dependencies(${target}${target_suffix}
"test_msgs") "rcl"
"test_msgs"
)
endif() endif()
endfunction() endfunction()
@ -156,12 +156,14 @@ if(BUILD_TESTING)
if(TARGET test_action_server) if(TARGET test_action_server)
target_include_directories(test_action_server PUBLIC target_include_directories(test_action_server PUBLIC
include include
${rcl_INCLUDE_DIRS}
) )
target_link_libraries(test_action_server target_link_libraries(test_action_server
${PROJECT_NAME} ${PROJECT_NAME}
) )
ament_target_dependencies(test_action_server "test_msgs") ament_target_dependencies(test_action_server
"rcl"
"test_msgs"
)
endif() endif()
ament_add_gtest(test_goal_handle ament_add_gtest(test_goal_handle
test/rcl_action/test_goal_handle.cpp test/rcl_action/test_goal_handle.cpp
@ -169,22 +171,20 @@ if(BUILD_TESTING)
if(TARGET test_goal_handle) if(TARGET test_goal_handle)
target_include_directories(test_goal_handle PUBLIC target_include_directories(test_goal_handle PUBLIC
include include
${rcl_INCLUDE_DIRS}
) )
target_link_libraries(test_goal_handle target_link_libraries(test_goal_handle
${PROJECT_NAME} ${PROJECT_NAME}
) )
ament_target_dependencies(test_action_server "rcl")
endif() endif()
ament_add_gtest(test_goal_state_machine ament_add_gtest(test_goal_state_machine
test/rcl_action/test_goal_state_machine.cpp test/rcl_action/test_goal_state_machine.cpp
) )
if(TARGET test_goal_state_machine) if(TARGET test_goal_state_machine)
target_include_directories(test_goal_state_machine PUBLIC
${rcl_INCLUDE_DIRS}
)
target_link_libraries(test_goal_state_machine target_link_libraries(test_goal_state_machine
${PROJECT_NAME} ${PROJECT_NAME}
) )
ament_target_dependencies(test_action_server "rcl")
endif() endif()
ament_add_gtest(test_types ament_add_gtest(test_types
test/rcl_action/test_types.cpp test/rcl_action/test_types.cpp
@ -192,22 +192,20 @@ if(BUILD_TESTING)
if(TARGET test_types) if(TARGET test_types)
target_include_directories(test_types PUBLIC target_include_directories(test_types PUBLIC
include include
${rcl_INCLUDE_DIRS}
) )
target_link_libraries(test_types target_link_libraries(test_types
${PROJECT_NAME} ${PROJECT_NAME}
) )
ament_target_dependencies(test_action_server "rcl")
endif() endif()
ament_add_gtest(test_names ament_add_gtest(test_names
test/rcl_action/test_names.cpp test/rcl_action/test_names.cpp
) )
if(TARGET test_names) if(TARGET test_names)
target_include_directories(test_names PUBLIC
${rcl_INCLUDE_DIRS}
)
target_link_libraries(test_names target_link_libraries(test_names
${PROJECT_NAME} ${PROJECT_NAME}
) )
ament_target_dependencies(test_action_server "rcl")
endif() endif()
endif() endif()

View file

@ -70,9 +70,9 @@ if(BUILD_TESTING)
test/test_default_state_machine.cpp test/test_default_state_machine.cpp
) )
if(TARGET test_default_state_machine) if(TARGET test_default_state_machine)
target_include_directories(test_default_state_machine PUBLIC ament_target_dependencies(test_default_state_machine
${rcl_INCLUDE_DIRS} "rcl"
${osrf_testing_tools_cpp_INCLUDE_DIRS} "osrf_testing_tools_cpp"
) )
target_link_libraries(test_default_state_machine ${PROJECT_NAME}) target_link_libraries(test_default_state_machine ${PROJECT_NAME})
endif() endif()
@ -80,9 +80,9 @@ if(BUILD_TESTING)
test/test_multiple_instances.cpp test/test_multiple_instances.cpp
) )
if(TARGET test_multiple_instances) if(TARGET test_multiple_instances)
target_include_directories(test_multiple_instances PUBLIC ament_target_dependencies(test_multiple_instances
${rcl_INCLUDE_DIRS} "rcl"
${osrf_testing_tools_cpp_INCLUDE_DIRS} "osrf_testing_tools_cpp"
) )
target_link_libraries(test_multiple_instances ${PROJECT_NAME}) target_link_libraries(test_multiple_instances ${PROJECT_NAME})
endif() endif()
@ -90,8 +90,8 @@ if(BUILD_TESTING)
test/test_transition_map.cpp test/test_transition_map.cpp
) )
if(TARGET test_transition_map) if(TARGET test_transition_map)
target_include_directories(test_transition_map PUBLIC ament_target_dependencies(test_transition_map
${rcl_INCLUDE_DIRS} "rcl"
) )
target_link_libraries(test_transition_map ${PROJECT_NAME}) target_link_libraries(test_transition_map ${PROJECT_NAME})
endif() endif()