From 99630cb66dc90644266e34ce6987c2b36b3a7602 Mon Sep 17 00:00:00 2001 From: ivanpauno Date: Tue, 19 Mar 2019 09:22:16 -0300 Subject: [PATCH] Using ament_target_dependencies where possible (#400) * Using ament_target_dependencies where possible Signed-off-by: ivanpauno * Modified rcl_add_custom_* to use AMENT_DEPENDENCIES where possible Signed-off-by: ivanpauno * Added again osrf_testing_tools_cpp::memory_tools library where needed. Signed-off-by: ivanpauno * Modified with PR comment, and replaced forgotten osrf_testing_tools_cpp including Signed-off-by: ivanpauno --- rcl/test/CMakeLists.txt | 51 +++++++++++++----------------------- rcl_action/CMakeLists.txt | 26 +++++++++--------- rcl_lifecycle/CMakeLists.txt | 16 +++++------ 3 files changed, 38 insertions(+), 55 deletions(-) diff --git a/rcl/test/CMakeLists.txt b/rcl/test/CMakeLists.txt index 6e17bd7ce..cd4e77fc5 100644 --- a/rcl/test/CMakeLists.txt +++ b/rcl/test/CMakeLists.txt @@ -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} @@ -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} @@ -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 "") @@ -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} @@ -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} @@ -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 @@ -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 @@ -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}) \ No newline at end of file + DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) diff --git a/rcl_action/CMakeLists.txt b/rcl_action/CMakeLists.txt index 75541e2fc..f16868b54 100644 --- a/rcl_action/CMakeLists.txt +++ b/rcl_action/CMakeLists.txt @@ -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 @@ -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() @@ -156,12 +156,14 @@ 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 @@ -169,22 +171,20 @@ if(BUILD_TESTING) 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 @@ -192,22 +192,20 @@ if(BUILD_TESTING) 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() diff --git a/rcl_lifecycle/CMakeLists.txt b/rcl_lifecycle/CMakeLists.txt index 3bf53351d..bcb4dc1d2 100644 --- a/rcl_lifecycle/CMakeLists.txt +++ b/rcl_lifecycle/CMakeLists.txt @@ -70,9 +70,9 @@ 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() @@ -80,9 +80,9 @@ if(BUILD_TESTING) 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() @@ -90,8 +90,8 @@ if(BUILD_TESTING) 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()