Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: use exported targets #69

Merged
merged 8 commits into from Aug 15, 2022
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
93 changes: 83 additions & 10 deletions CMakeLists.txt
@@ -1,33 +1,106 @@
cmake_minimum_required(VERSION 3.5)
project(pointcloud_to_laserscan)

find_package(ament_cmake_auto REQUIRED)
ament_auto_find_build_dependencies()
find_package(ament_cmake REQUIRED)

ament_auto_add_library(laserscan_to_pointcloud SHARED
src/laserscan_to_pointcloud_node.cpp)
find_package(laser_geometry REQUIRED)
find_package(message_filters REQUIRED)
find_package(rclcpp REQUIRED)
find_package(rclcpp_components REQUIRED)
find_package(sensor_msgs REQUIRED)
find_package(tf2 REQUIRED)
find_package(tf2_ros REQUIRED)
find_package(tf2_sensor_msgs REQUIRED)

add_library(laserscan_to_pointcloud SHARED
src/laserscan_to_pointcloud_node.cpp)
target_compile_definitions(laserscan_to_pointcloud
PRIVATE "POINTCLOUD_TO_LASERSCAN_BUILDING_DLL")
target_include_directories(laserscan_to_pointcloud PUBLIC
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
"$<INSTALL_INTERFACE:include/${PROJECT_NAME}>"
)
target_link_libraries(laserscan_to_pointcloud
laser_geometry::laser_geometry
message_filters::message_filters
rclcpp::rclcpp
rclcpp_components::component
tf2::tf2
tf2_ros::tf2_ros
# use exported target after https://github.com/ros2/geometry2/pull/536 is merged
# tf2_sensor_msgs::tf2_sensor_msgs
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So when I tried to build this, it failed with:

pc_to_laserscan_ws/src/pointcloud_to_laserscan/src/pointcloud_to_laserscan_node.cpp:52:10: fatal error: tf2_sensor_msgs/tf2_sensor_msgs.h: No such file or directory
   52 | #include "tf2_sensor_msgs/tf2_sensor_msgs.h"

A workaround would be to add ${tf2_sensor_msgs_INCLUDE_DIRS} to the target_include_directories. We can either do that, or we can wait for ros2/geometry2#536 to be merged. I leave the decision to you, either is fine with me.

Copy link
Contributor Author

@wep21 wep21 Jun 28, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@clalancette I decided to add workaround until ros2/geometry2#536 is merged. f4e8781
Thank you for letting me know.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@clalancette friendly ping

"${sensor_msgs_TARGETS}"
)
rclcpp_components_register_node(laserscan_to_pointcloud
PLUGIN "pointcloud_to_laserscan::LaserScanToPointCloudNode"
EXECUTABLE laserscan_to_pointcloud_node)

ament_auto_add_library(pointcloud_to_laserscan SHARED
add_library(pointcloud_to_laserscan SHARED
src/pointcloud_to_laserscan_node.cpp)

target_compile_definitions(pointcloud_to_laserscan
PRIVATE "POINTCLOUD_TO_LASERSCAN_BUILDING_DLL")
target_include_directories(pointcloud_to_laserscan PUBLIC
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
"$<INSTALL_INTERFACE:include/${PROJECT_NAME}>"
)
target_link_libraries(pointcloud_to_laserscan
laser_geometry::laser_geometry
message_filters::message_filters
rclcpp::rclcpp
rclcpp_components::component
tf2::tf2
tf2_ros::tf2_ros
# use exported target after https://github.com/ros2/geometry2/pull/536 is merged
# tf2_sensor_msgs::tf2_sensor_msgs
"${sensor_msgs_TARGETS}"
)
rclcpp_components_register_node(pointcloud_to_laserscan
PLUGIN "pointcloud_to_laserscan::PointCloudToLaserScanNode"
EXECUTABLE pointcloud_to_laserscan_node)

ament_auto_add_executable(dummy_pointcloud_publisher
add_executable(dummy_pointcloud_publisher
src/dummy_pointcloud_publisher.cpp
)
target_link_libraries(dummy_pointcloud_publisher
rclcpp::rclcpp
"${sensor_msgs_TARGETS}"
)

install(TARGETS
laserscan_to_pointcloud
pointcloud_to_laserscan
wep21 marked this conversation as resolved.
Show resolved Hide resolved
EXPORT export_${PROJECT_NAME}
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib)

install(TARGETS
dummy_pointcloud_publisher
DESTINATION lib/${PROJECT_NAME}
)

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

install(DIRECTORY launch
DESTINATION share/${PROJECT_NAME}
)

if(BUILD_TESTING)
find_package(ament_lint_auto REQUIRED)
ament_lint_auto_find_test_dependencies()
endif()

ament_auto_package(
INSTALL_TO_SHARE
launch
ament_export_dependencies(
laser_geometry
message_filters
rclcpp
rclcpp_components
sensor_msgs
tf2
tf2_ros
tf2_sensor_msgs
)

ament_package()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are missing the export of the dependencies. This should be something like:

ament_export_dependencies(laser_geometry message_filters rclcpp sensor_msgs tf2_ros)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@clalancette I added missing ament_export_dependencies in be9226b.

2 changes: 1 addition & 1 deletion package.xml
Expand Up @@ -16,7 +16,7 @@
<url type="bugtracker">https://github.com/ros-perception/perception_pcl/issues</url>
<url type="repository">https://github.com/ros-perception/perception_pcl</url>

<buildtool_depend>ament_cmake_auto</buildtool_depend>
<buildtool_depend>ament_cmake</buildtool_depend>

<depend>laser_geometry</depend>
<depend>message_filters</depend>
Expand Down