Skip to content

Commit

Permalink
Use ament_export_targets for all targets
Browse files Browse the repository at this point in the history
* Matches new internal ALIAS targets
* Use ALIAS targets for all internal linkage
* Remove unnecessary calls to ament_target_dependencies in test code
* Export includes in proper folders for overlays in colcon

Signed-off-by: Ryan Friedman <ryanfriedman5410+github@gmail.com>
  • Loading branch information
Ryanf55 committed Feb 12, 2024
1 parent 70dc1f9 commit 6056680
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 85 deletions.
53 changes: 27 additions & 26 deletions nav2_costmap_2d/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,10 @@ find_package(visualization_msgs REQUIRED)
find_package(angles REQUIRED)

remove_definitions(-DDISABLE_LIBUSB-1.0)
find_package(Eigen3 REQUIRED)
find_package(Eigen3 3.3 REQUIRED)

nav2_package()

include_directories(
include
${EIGEN3_INCLUDE_DIRS}
)

add_definitions(${EIGEN3_DEFINITIONS})

add_library(nav2_costmap_2d_core SHARED
src/costmap_2d.cpp
src/layer.cpp
Expand All @@ -51,6 +44,13 @@ add_library(nav2_costmap_2d_core SHARED
src/footprint_collision_checker.cpp
plugins/costmap_filters/costmap_filter.cpp
)
add_library(${PROJECT_NAME}::nav2_costmap_2d_core ALIAS nav2_costmap_2d_core)

target_include_directories(nav2_costmap_2d_core
PUBLIC
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
"$<INSTALL_INTERFACE:include/${PROJECT_NAME}>"
)

set(dependencies
geometry_msgs
Expand Down Expand Up @@ -78,6 +78,7 @@ set(dependencies
ament_target_dependencies(nav2_costmap_2d_core
${dependencies}
)
target_link_libraries(nav2_costmap_2d_core Eigen3::Eigen)

add_library(layers SHARED
plugins/inflation_layer.cpp
Expand All @@ -88,42 +89,47 @@ add_library(layers SHARED
plugins/range_sensor_layer.cpp
plugins/denoise_layer.cpp
)
add_library(${PROJECT_NAME}::layers ALIAS layers)
ament_target_dependencies(layers
${dependencies}
)
target_link_libraries(layers
nav2_costmap_2d_core
${PROJECT_NAME}::nav2_costmap_2d_core
)

add_library(filters SHARED
plugins/costmap_filters/keepout_filter.cpp
plugins/costmap_filters/speed_filter.cpp
plugins/costmap_filters/binary_filter.cpp
)
add_library(${PROJECT_NAME}::filters ALIAS filters)


ament_target_dependencies(filters
${dependencies}
)
target_link_libraries(filters
nav2_costmap_2d_core
${PROJECT_NAME}::nav2_costmap_2d_core
)

add_library(nav2_costmap_2d_client SHARED
src/footprint_subscriber.cpp
src/costmap_subscriber.cpp
src/costmap_topic_collision_checker.cpp
)
add_library(${PROJECT_NAME}::nav2_costmap_2d_client ALIAS nav2_costmap_2d_client)

ament_target_dependencies(nav2_costmap_2d_client
${dependencies}
)

target_link_libraries(nav2_costmap_2d_client
nav2_costmap_2d_core
${PROJECT_NAME}::nav2_costmap_2d_core
)

add_executable(nav2_costmap_2d_markers src/costmap_2d_markers.cpp)
target_link_libraries(nav2_costmap_2d_markers
nav2_costmap_2d_core
${PROJECT_NAME}::nav2_costmap_2d_core
)

ament_target_dependencies(nav2_costmap_2d_markers
Expand All @@ -132,7 +138,7 @@ ament_target_dependencies(nav2_costmap_2d_markers

add_executable(nav2_costmap_2d_cloud src/costmap_2d_cloud.cpp)
target_link_libraries(nav2_costmap_2d_cloud
nav2_costmap_2d_core
${PROJECT_NAME}::nav2_costmap_2d_core
)

add_executable(nav2_costmap_2d src/costmap_2d_node.cpp)
Expand All @@ -141,34 +147,30 @@ ament_target_dependencies(nav2_costmap_2d
)

target_link_libraries(nav2_costmap_2d
nav2_costmap_2d_core
${PROJECT_NAME}::nav2_costmap_2d_core
layers
filters
${PROJECT_NAME}::filters
)

install(TARGETS
nav2_costmap_2d_core
layers
filters
nav2_costmap_2d_core
nav2_costmap_2d_client
nav2_costmap_2d_markers
nav2_costmap_2d_cloud
EXPORT export_${PROJECT_NAME}
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
RUNTIME DESTINATION bin
)

install(TARGETS
nav2_costmap_2d
nav2_costmap_2d_markers
nav2_costmap_2d_cloud
RUNTIME DESTINATION lib/${PROJECT_NAME}
)

install(FILES costmap_plugins.xml
DESTINATION share/${PROJECT_NAME}
)

install(DIRECTORY include/
DESTINATION include/
DESTINATION include/${PROJECT_NAME}
)

if(BUILD_TESTING)
Expand All @@ -183,8 +185,7 @@ if(BUILD_TESTING)
pluginlib_export_plugin_description_file(nav2_costmap_2d test/regression/order_layer.xml)
endif()

ament_export_include_directories(include)
ament_export_libraries(layers filters nav2_costmap_2d_core nav2_costmap_2d_client)
ament_export_targets(export_${PROJECT_NAME} HAS_LIBRARY_TARGET)
ament_export_dependencies(${dependencies})
pluginlib_export_plugin_description_file(nav2_costmap_2d costmap_plugins.xml)
ament_package()
60 changes: 18 additions & 42 deletions nav2_costmap_2d/test/integration/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,90 +1,66 @@
ament_add_gtest_executable(footprint_tests_exec
footprint_tests.cpp
)
ament_target_dependencies(footprint_tests_exec
${dependencies}
)
target_link_libraries(footprint_tests_exec
nav2_costmap_2d_core
layers
${PROJECT_NAME}::nav2_costmap_2d_core
${PROJECT_NAME}::layers
)

ament_add_gtest_executable(test_collision_checker_exec
test_costmap_topic_collision_checker.cpp
)
ament_target_dependencies(test_collision_checker_exec
${dependencies}
)
target_link_libraries(test_collision_checker_exec
nav2_costmap_2d_core
nav2_costmap_2d_client
layers
${PROJECT_NAME}::nav2_costmap_2d_core
${PROJECT_NAME}::nav2_costmap_2d_client
${PROJECT_NAME}::layers
)

ament_add_gtest_executable(inflation_tests_exec
inflation_tests.cpp
)
ament_target_dependencies(inflation_tests_exec
${dependencies}
)
target_link_libraries(inflation_tests_exec
nav2_costmap_2d_core
layers
${PROJECT_NAME}::nav2_costmap_2d_core
${PROJECT_NAME}::layers
)

ament_add_gtest_executable(obstacle_tests_exec
obstacle_tests.cpp
)
ament_target_dependencies(obstacle_tests_exec
${dependencies}
)
target_link_libraries(obstacle_tests_exec
nav2_costmap_2d_core
layers
${PROJECT_NAME}::nav2_costmap_2d_core
${PROJECT_NAME}::layers
)

ament_add_gtest_executable(range_tests_exec
range_tests.cpp
)
ament_target_dependencies(range_tests_exec
${dependencies}
)
target_link_libraries(range_tests_exec
nav2_costmap_2d_core
layers
${PROJECT_NAME}::nav2_costmap_2d_core
${PROJECT_NAME}::layers
)

ament_add_gtest(dyn_params_tests
dyn_params_tests.cpp
)
ament_target_dependencies(dyn_params_tests
${dependencies}
)
target_link_libraries(dyn_params_tests
nav2_costmap_2d_core
${PROJECT_NAME}::nav2_costmap_2d_core
)

ament_add_gtest_executable(test_costmap_publisher_exec
test_costmap_2d_publisher.cpp
)
ament_target_dependencies(test_costmap_publisher_exec
${dependencies}
)
target_link_libraries(test_costmap_publisher_exec
nav2_costmap_2d_core
nav2_costmap_2d_client
layers
${PROJECT_NAME}::nav2_costmap_2d_core
${PROJECT_NAME}::nav2_costmap_2d_client
${PROJECT_NAME}::layers
)

ament_add_gtest_executable(test_costmap_subscriber_exec
test_costmap_subscriber.cpp
)
ament_target_dependencies(test_costmap_subscriber_exec
${dependencies}
)
target_link_libraries(test_costmap_subscriber_exec
nav2_costmap_2d_core
nav2_costmap_2d_client
${PROJECT_NAME}::nav2_costmap_2d_core
${PROJECT_NAME}::nav2_costmap_2d_client
)

ament_add_test(test_collision_checker
Expand Down Expand Up @@ -166,6 +142,6 @@ ament_add_test(test_costmap_subscriber_exec
# ${dependencies}
# )
# target_link_libraries(costmap_tester
# nav2_costmap_2d_core
# ${PROJECT_NAME}::nav2_costmap_2d_core
# layers
# )
6 changes: 3 additions & 3 deletions nav2_costmap_2d/test/regression/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Bresenham2D corner cases test
ament_add_gtest(costmap_bresenham_2d costmap_bresenham_2d.cpp)
target_link_libraries(costmap_bresenham_2d
nav2_costmap_2d_core
${PROJECT_NAME}::nav2_costmap_2d_core
)

# OrderLayer for checking Costmap2D plugins API calling order
Expand All @@ -11,7 +11,7 @@ ament_target_dependencies(order_layer
${dependencies}
)
target_link_libraries(order_layer
nav2_costmap_2d_core
${PROJECT_NAME}::nav2_costmap_2d_core
)
install(TARGETS
order_layer
Expand All @@ -23,5 +23,5 @@ install(TARGETS
# Costmap2D plugins API calling order test
ament_add_gtest(plugin_api_order plugin_api_order.cpp)
target_link_libraries(plugin_api_order
nav2_costmap_2d_core
${PROJECT_NAME}::nav2_costmap_2d_core
)
29 changes: 15 additions & 14 deletions nav2_costmap_2d/test/unit/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,57 +1,58 @@
ament_add_gtest(collision_footprint_test footprint_collision_checker_test.cpp)
target_link_libraries(collision_footprint_test
nav2_costmap_2d_core
${PROJECT_NAME}::nav2_costmap_2d_core
)

ament_add_gtest(costmap_convesion_test costmap_conversion_test.cpp)
target_link_libraries(costmap_convesion_test
nav2_costmap_2d_core
${PROJECT_NAME}::nav2_costmap_2d_core
)

ament_add_gtest(declare_parameter_test declare_parameter_test.cpp)
target_link_libraries(declare_parameter_test
nav2_costmap_2d_core
${PROJECT_NAME}::nav2_costmap_2d_core
)

ament_add_gtest(costmap_filter_test costmap_filter_test.cpp)
target_link_libraries(costmap_filter_test
nav2_costmap_2d_core
${PROJECT_NAME}::nav2_costmap_2d_core
)

ament_add_gtest(keepout_filter_test keepout_filter_test.cpp)
target_link_libraries(keepout_filter_test
nav2_costmap_2d_core
filters
${PROJECT_NAME}::nav2_costmap_2d_core
${PROJECT_NAME}::filters
)

ament_add_gtest(speed_filter_test speed_filter_test.cpp)
target_link_libraries(speed_filter_test
nav2_costmap_2d_core
filters
${PROJECT_NAME}::nav2_costmap_2d_core
${PROJECT_NAME}::filters
)

ament_add_gtest(binary_filter_test binary_filter_test.cpp)
target_link_libraries(binary_filter_test
nav2_costmap_2d_core
filters
${PROJECT_NAME}::nav2_costmap_2d_core
${PROJECT_NAME}::filters
)

ament_add_gtest(copy_window_test copy_window_test.cpp)
target_link_libraries(copy_window_test
nav2_costmap_2d_core
${PROJECT_NAME}::nav2_costmap_2d_core
)

ament_add_gtest(costmap_filter_service_test costmap_filter_service_test.cpp)
target_link_libraries(costmap_filter_service_test
nav2_costmap_2d_core
${PROJECT_NAME}::nav2_costmap_2d_core
)

ament_add_gtest(denoise_layer_test denoise_layer_test.cpp image_test.cpp image_processing_test.cpp)
target_link_libraries(denoise_layer_test
nav2_costmap_2d_core layers
${PROJECT_NAME}::nav2_costmap_2d_core
${PROJECT_NAME}::layers
)

ament_add_gtest(lifecycle_test lifecycle_test.cpp)
target_link_libraries(lifecycle_test
nav2_costmap_2d_core
${PROJECT_NAME}::nav2_costmap_2d_core
)

0 comments on commit 6056680

Please sign in to comment.