Skip to content
This repository was archived by the owner on Jul 23, 2024. It is now read-only.

Commit 9e94db4

Browse files
authored
Export a tf2_geometry_msgs::tf2_geometry_msgs target (ros#496)
* Export a tf2_geometry_msgs::tf2_geometry_msgs target Signed-off-by: Shane Loretz <sloretz@openrobotics.org> * Comment that tf2_ros is used but intentionally not linked Signed-off-by: Shane Loretz <sloretz@osrfoundation.org>
1 parent 411ccff commit 9e94db4

2 files changed

Lines changed: 29 additions & 27 deletions

File tree

tf2_geometry_msgs/CMakeLists.txt

Lines changed: 28 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,10 @@ if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
99
add_compile_options(-Wall -Wextra -Wpedantic -Wnon-virtual-dtor -Woverloaded-virtual)
1010
endif()
1111

12-
find_package(ament_cmake_auto REQUIRED)
13-
set(required_dependencies
14-
"geometry_msgs"
15-
"orocos_kdl"
16-
"tf2"
17-
"tf2_ros"
18-
)
19-
ament_auto_find_build_dependencies(REQUIRED ${required_dependencies})
12+
find_package(geometry_msgs REQUIRED)
13+
find_package(orocos_kdl REQUIRED)
14+
find_package(tf2 REQUIRED)
15+
find_package(tf2_ros REQUIRED)
2016

2117
# TODO(ros2/geometry2#110) Port python once PyKDL becomes usable in ROS 2
2218
# ament_python_install_package(${PROJECT_NAME}
@@ -27,6 +23,16 @@ ament_auto_find_build_dependencies(REQUIRED ${required_dependencies})
2723
# DESTINATION lib/${PROJECT_NAME}
2824
# )
2925

26+
add_library(${PROJECT_NAME} INTERFACE)
27+
target_include_directories(${PROJECT_NAME} INTERFACE
28+
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
29+
"$<INSTALL_INTERFACE:include>")
30+
target_link_libraries(${PROJECT_NAME} INTERFACE
31+
${geometry_msgs_TARGETS}
32+
orocos-kdl
33+
tf2::tf2
34+
tf2_ros::tf2_ros)
35+
3036
if(BUILD_TESTING)
3137
find_package(ament_lint_auto REQUIRED)
3238

@@ -42,27 +48,23 @@ if(BUILD_TESTING)
4248

4349
ament_add_gtest(test_tf2_geometry_msgs test/test_tf2_geometry_msgs.cpp)
4450
if(TARGET test_tf2_geometry_msgs)
45-
target_include_directories(test_tf2_geometry_msgs PUBLIC include)
46-
ament_target_dependencies(test_tf2_geometry_msgs
47-
"geometry_msgs"
48-
"orocos_kdl"
49-
"rclcpp"
50-
"tf2"
51-
"tf2_ros"
51+
target_link_libraries(test_tf2_geometry_msgs
52+
${PROJECT_NAME}
53+
rclcpp::rclcpp
54+
# Used, but not linked to test ${PROJECT_NAME}'s exports:
55+
# tf2_ros::tf2_ros
5256
)
5357
endif()
5458
endif()
5559

56-
add_library(${PROJECT_NAME} INTERFACE)
57-
target_include_directories(${PROJECT_NAME} INTERFACE $<INSTALL_INTERFACE:include>)
58-
ament_target_dependencies(${PROJECT_NAME} INTERFACE ${required_dependencies})
59-
60-
install(
61-
TARGETS ${PROJECT_NAME} EXPORT ${PROJECT_NAME}
62-
INCLUDES DESTINATION include
63-
)
60+
install(TARGETS ${PROJECT_NAME} EXPORT export_${PROJECT_NAME})
61+
install(DIRECTORY include/ DESTINATION include)
6462

65-
ament_export_targets(${PROJECT_NAME})
66-
ament_export_dependencies(${required_dependencies})
63+
ament_export_targets(export_${PROJECT_NAME})
64+
ament_export_dependencies(
65+
"geometry_msgs"
66+
"orocos_kdl"
67+
"tf2"
68+
"tf2_ros")
6769

68-
ament_auto_package()
70+
ament_package()

tf2_geometry_msgs/package.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<author email="tfoote@osrfoundation.org">Tully Foote</author>
1212
<author>Wim Meeussen</author>
1313

14-
<buildtool_depend>ament_cmake_auto</buildtool_depend>
14+
<buildtool_depend>ament_cmake</buildtool_depend>
1515

1616
<depend>geometry_msgs</depend>
1717
<depend>orocos_kdl</depend>

0 commit comments

Comments
 (0)