Skip to content

Commit

Permalink
Using ament_target_dependencies where possible (#400)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
ivanpauno authored Mar 19, 2019
1 parent 29b0838 commit 99630cb
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 55 deletions.
51 changes: 18 additions & 33 deletions rcl/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,10 @@ function(test_target_function)

rcl_add_custom_gtest(test_client${target_suffix}
SRCS rcl/test_client.cpp
INCLUDE_DIRS ${osrf_testing_tools_cpp_INCLUDE_DIRS}
ENV ${rmw_implementation_env_var}
APPEND_LIBRARY_DIRS ${extra_lib_dirs}
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}
Expand Down Expand Up @@ -71,11 +70,10 @@ function(test_target_function)

rcl_add_custom_gtest(test_get_node_names${target_suffix}
SRCS rcl/test_get_node_names.cpp
INCLUDE_DIRS ${osrf_testing_tools_cpp_INCLUDE_DIRS}
ENV ${rmw_implementation_env_var}
APPEND_LIBRARY_DIRS ${extra_lib_dirs}
LIBRARIES ${PROJECT_NAME}
AMENT_DEPENDENCIES ${rmw_implementation}
AMENT_DEPENDENCIES ${rmw_implementation} "osrf_testing_tools_cpp"
)

rcl_add_custom_gtest(test_lexer${target_suffix}
Expand All @@ -88,11 +86,10 @@ function(test_target_function)

rcl_add_custom_gtest(test_lexer_lookahead${target_suffix}
SRCS rcl/test_lexer_lookahead.cpp
INCLUDE_DIRS ${osrf_testing_tools_cpp_INCLUDE_DIRS}
ENV ${rmw_implementation_env_var}
APPEND_LIBRARY_DIRS ${extra_lib_dirs}
LIBRARIES ${PROJECT_NAME}
AMENT_DEPENDENCIES ${rmw_implementation}
AMENT_DEPENDENCIES ${rmw_implementation} "osrf_testing_tools_cpp"
)

set(AMENT_GTEST_ARGS "")
Expand All @@ -107,21 +104,19 @@ function(test_target_function)
endif()
rcl_add_custom_gtest(test_graph${target_suffix}
SRCS rcl/test_graph.cpp
INCLUDE_DIRS ${osrf_testing_tools_cpp_INCLUDE_DIRS}
ENV ${rmw_implementation_env_var}
APPEND_LIBRARY_DIRS ${extra_lib_dirs}
LIBRARIES ${PROJECT_NAME}
AMENT_DEPENDENCIES ${rmw_implementation} "test_msgs"
AMENT_DEPENDENCIES ${rmw_implementation} "osrf_testing_tools_cpp" "test_msgs"
${AMENT_GTEST_ARGS}
)

rcl_add_custom_gtest(test_count_matched${target_suffix}
SRCS rcl/test_count_matched.cpp
INCLUDE_DIRS ${osrf_testing_tools_cpp_INCLUDE_DIRS}
ENV ${rmw_implementation_env_var}
APPEND_LIBRARY_DIRS ${extra_lib_dirs}
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}
Expand All @@ -134,11 +129,10 @@ function(test_target_function)

rcl_add_custom_gtest(test_node${target_suffix}
SRCS rcl/test_node.cpp
INCLUDE_DIRS ${osrf_testing_tools_cpp_INCLUDE_DIRS}
ENV ${rmw_implementation_env_var} ${memory_tools_ld_preload_env_var}
APPEND_LIBRARY_DIRS ${extra_lib_dirs}
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}
Expand All @@ -150,90 +144,81 @@ function(test_target_function)

rcl_add_custom_gtest(test_remap${target_suffix}
SRCS rcl/test_remap.cpp
INCLUDE_DIRS ${osrf_testing_tools_cpp_INCLUDE_DIRS}
ENV ${rmw_implementation_env_var}
APPEND_LIBRARY_DIRS ${extra_lib_dirs}
LIBRARIES ${PROJECT_NAME}
AMENT_DEPENDENCIES "osrf_testing_tools_cpp"
)

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

rcl_add_custom_gtest(test_guard_condition${target_suffix}
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}
APPEND_LIBRARY_DIRS ${extra_lib_dirs}
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}
SRCS rcl/test_publisher.cpp
INCLUDE_DIRS ${osrf_testing_tools_cpp_INCLUDE_DIRS}
ENV ${rmw_implementation_env_var}
APPEND_LIBRARY_DIRS ${extra_lib_dirs}
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}
SRCS rcl/test_service.cpp
INCLUDE_DIRS ${osrf_testing_tools_cpp_INCLUDE_DIRS}
ENV ${rmw_implementation_env_var}
APPEND_LIBRARY_DIRS ${extra_lib_dirs}
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}
SRCS rcl/test_subscription.cpp
INCLUDE_DIRS ${osrf_testing_tools_cpp_INCLUDE_DIRS}
ENV ${rmw_implementation_env_var}
APPEND_LIBRARY_DIRS ${extra_lib_dirs}
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}
SRCS rcl/test_wait.cpp
INCLUDE_DIRS ${osrf_testing_tools_cpp_INCLUDE_DIRS}
ENV ${rmw_implementation_env_var}
APPEND_LIBRARY_DIRS ${extra_lib_dirs}
LIBRARIES ${PROJECT_NAME}
AMENT_DEPENDENCIES ${rmw_implementation}
AMENT_DEPENDENCIES ${rmw_implementation} "osrf_testing_tools_cpp"
)

rcl_add_custom_gtest(test_namespace${target_suffix}
SRCS test_namespace.cpp
INCLUDE_DIRS ${osrf_testing_tools_cpp_INCLUDE_DIRS}
ENV ${rmw_implementation_env_var}
APPEND_LIBRARY_DIRS ${extra_lib_dirs}
LIBRARIES ${PROJECT_NAME}
AMENT_DEPENDENCIES ${rmw_implementation} "test_msgs"
AMENT_DEPENDENCIES ${rmw_implementation} "osrf_testing_tools_cpp" "test_msgs"
)

# Launch tests

rcl_add_custom_executable(service_fixture${target_suffix}
SRCS rcl/service_fixture.cpp
INCLUDE_DIRS ${osrf_testing_tools_cpp_INCLUDE_DIRS}
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}
SRCS rcl/client_fixture.cpp
INCLUDE_DIRS ${osrf_testing_tools_cpp_INCLUDE_DIRS}
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
Expand Down Expand Up @@ -296,9 +281,9 @@ rcl_add_custom_gtest(test_expand_topic_name

rcl_add_custom_gtest(test_timer${target_suffix}
SRCS rcl/test_timer.cpp
INCLUDE_DIRS ${osrf_testing_tools_cpp_INCLUDE_DIRS}
APPEND_LIBRARY_DIRS ${extra_lib_dirs}
LIBRARIES ${PROJECT_NAME}
AMENT_DEPENDENCIES "osrf_testing_tools_cpp"
)

rcl_add_custom_gtest(test_security_directory
Expand All @@ -309,4 +294,4 @@ rcl_add_custom_gtest(test_security_directory

# Install test resources
install(DIRECTORY ${test_resources_dir_name}
DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
26 changes: 12 additions & 14 deletions rcl_action/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,11 @@ if(BUILD_TESTING)
if(TARGET test_action_client)
target_include_directories(test_action_client PUBLIC
include
${osrf_testing_tools_cpp_INCLUDE_DIRS}
)
target_link_libraries(test_action_client
${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()

# get the rmw implementations ahead of time
Expand All @@ -118,13 +117,14 @@ if(BUILD_TESTING)
PUBLIC "RMW_IMPLEMENTATION=${rmw_implementation}")
target_include_directories(${target}${target_suffix} PUBLIC
include
${rcl_INCLUDE_DIRS}
)
target_link_libraries(${target}${target_suffix}
${PROJECT_NAME}
)
ament_target_dependencies(${target}${target_suffix}
"test_msgs")
"rcl"
"test_msgs"
)
endif()
endfunction()

Expand Down Expand Up @@ -156,58 +156,56 @@ if(BUILD_TESTING)
if(TARGET test_action_server)
target_include_directories(test_action_server PUBLIC
include
${rcl_INCLUDE_DIRS}
)
target_link_libraries(test_action_server
${PROJECT_NAME}
)
ament_target_dependencies(test_action_server "test_msgs")
ament_target_dependencies(test_action_server
"rcl"
"test_msgs"
)
endif()
ament_add_gtest(test_goal_handle
test/rcl_action/test_goal_handle.cpp
)
if(TARGET test_goal_handle)
target_include_directories(test_goal_handle PUBLIC
include
${rcl_INCLUDE_DIRS}
)
target_link_libraries(test_goal_handle
${PROJECT_NAME}
)
ament_target_dependencies(test_action_server "rcl")
endif()
ament_add_gtest(test_goal_state_machine
test/rcl_action/test_goal_state_machine.cpp
)
if(TARGET test_goal_state_machine)
target_include_directories(test_goal_state_machine PUBLIC
${rcl_INCLUDE_DIRS}
)
target_link_libraries(test_goal_state_machine
${PROJECT_NAME}
)
ament_target_dependencies(test_action_server "rcl")
endif()
ament_add_gtest(test_types
test/rcl_action/test_types.cpp
)
if(TARGET test_types)
target_include_directories(test_types PUBLIC
include
${rcl_INCLUDE_DIRS}
)
target_link_libraries(test_types
${PROJECT_NAME}
)
ament_target_dependencies(test_action_server "rcl")
endif()
ament_add_gtest(test_names
test/rcl_action/test_names.cpp
)
if(TARGET test_names)
target_include_directories(test_names PUBLIC
${rcl_INCLUDE_DIRS}
)
target_link_libraries(test_names
${PROJECT_NAME}
)
ament_target_dependencies(test_action_server "rcl")
endif()
endif()

Expand Down
16 changes: 8 additions & 8 deletions rcl_lifecycle/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -70,28 +70,28 @@ if(BUILD_TESTING)
test/test_default_state_machine.cpp
)
if(TARGET test_default_state_machine)
target_include_directories(test_default_state_machine PUBLIC
${rcl_INCLUDE_DIRS}
${osrf_testing_tools_cpp_INCLUDE_DIRS}
ament_target_dependencies(test_default_state_machine
"rcl"
"osrf_testing_tools_cpp"
)
target_link_libraries(test_default_state_machine ${PROJECT_NAME})
endif()
ament_add_gtest(test_multiple_instances
test/test_multiple_instances.cpp
)
if(TARGET test_multiple_instances)
target_include_directories(test_multiple_instances PUBLIC
${rcl_INCLUDE_DIRS}
${osrf_testing_tools_cpp_INCLUDE_DIRS}
ament_target_dependencies(test_multiple_instances
"rcl"
"osrf_testing_tools_cpp"
)
target_link_libraries(test_multiple_instances ${PROJECT_NAME})
endif()
ament_add_gtest(test_transition_map
test/test_transition_map.cpp
)
if(TARGET test_transition_map)
target_include_directories(test_transition_map PUBLIC
${rcl_INCLUDE_DIRS}
ament_target_dependencies(test_transition_map
"rcl"
)
target_link_libraries(test_transition_map ${PROJECT_NAME})
endif()
Expand Down

0 comments on commit 99630cb

Please sign in to comment.