Skip to content

Commit e3fad51

Browse files
authored
Merge pull request #448 from ANYbotics/mergify/bp/iron/pr-424
Use ament_export_targets in grid_map_costmap_2d (backport #424)
2 parents c116f0f + d4dec3c commit e3fad51

File tree

2 files changed

+39
-17
lines changed

2 files changed

+39
-17
lines changed

grid_map_costmap_2d/CMakeLists.txt

Lines changed: 34 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
cmake_minimum_required(VERSION 3.5)
1+
cmake_minimum_required(VERSION 3.13)
22
project(grid_map_costmap_2d)
33

44
## Find ament_cmake macros and libraries
@@ -14,16 +14,6 @@ find_package(Eigen3 REQUIRED)
1414

1515
grid_map_package()
1616

17-
## Specify additional locations of header files
18-
include_directories(
19-
include
20-
SYSTEM
21-
${EIGEN3_INCLUDE_DIR}
22-
${grid_map_core_INCLUDE_DIRS}
23-
${nav2_costmap_2d_INCLUDE_DIRS}
24-
${geometry_msgs_INCLUDE_DIRS}
25-
)
26-
2717
set(dependencies
2818
grid_map_core
2919
geometry_msgs
@@ -32,13 +22,44 @@ set(dependencies
3222
tf2_geometry_msgs
3323
)
3424

25+
add_library(${PROJECT_NAME} INTERFACE
26+
include/grid_map_costmap_2d/costmap_2d_converter.hpp
27+
include/grid_map_costmap_2d/grid_map_costmap_2d.hpp
28+
)
29+
30+
add_library(${PROJECT_NAME}::${PROJECT_NAME} ALIAS ${PROJECT_NAME})
31+
32+
target_link_libraries(${PROJECT_NAME}
33+
INTERFACE
34+
grid_map_core::grid_map_core
35+
${geometry_msgs_TARGETS}
36+
${tf2_geometry_msgs_TARGETS}
37+
nav2_costmap_2d::nav2_costmap_2d_core
38+
tf2_ros::tf2_ros
39+
)
40+
41+
target_include_directories(${PROJECT_NAME}
42+
INTERFACE
43+
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
44+
"$<INSTALL_INTERFACE:include/${PROJECT_NAME}>"
45+
)
46+
3547
#############
3648
## Install ##
3749
#############
3850

51+
# Mark library for installation
52+
install(
53+
TARGETS ${PROJECT_NAME}
54+
EXPORT export_${PROJECT_NAME}
55+
LIBRARY DESTINATION lib
56+
ARCHIVE DESTINATION lib
57+
RUNTIME DESTINATION lib/${PROJECT_NAME}
58+
)
59+
3960
# Mark cpp header files for installation
4061
install(
41-
DIRECTORY include/${PROJECT_NAME}/
62+
DIRECTORY include/
4263
DESTINATION include/${PROJECT_NAME}
4364
FILES_MATCHING PATTERN "*.hpp"
4465
)
@@ -77,6 +98,6 @@ if(BUILD_TESTING)
7798
add_subdirectory(test)
7899
endif()
79100

80-
ament_export_include_directories(include)
101+
ament_export_targets(export_${PROJECT_NAME} HAS_LIBRARY_TARGET)
81102
ament_export_dependencies(${dependencies})
82103
ament_package()

grid_map_costmap_2d/test/CMakeLists.txt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,15 @@ ament_add_gtest(${PROJECT_NAME}-test
33
test_costmap_2d_converter.cpp
44
)
55

6-
ament_target_dependencies(${PROJECT_NAME}-test
7-
${dependencies}
6+
target_link_libraries(${PROJECT_NAME}-test
7+
${PROJECT_NAME}::${PROJECT_NAME}
88
)
99

1010
ament_add_gtest(costmap-2d-ros-test
1111
test_costmap_2d_ros.cpp
1212
)
1313

14-
ament_target_dependencies(costmap-2d-ros-test
15-
${dependencies}
14+
target_link_libraries(costmap-2d-ros-test
15+
${PROJECT_NAME}::${PROJECT_NAME}
1616
)
17+

0 commit comments

Comments
 (0)