[ROS2] CMake Error When Building the Package
Hi, I recently downloaded the pointcloudtolaserscan package from ROS Perception using github. However, after I installed the dependencies and tried to build the package, the errors suggested me that a the rclcppcomponents and tf2sensormsgs package was not found, yet I am sure that the findpackage() call was in the CMakeLists file. Weirdly enough the other linked librabies such as lasergeometry and messagefilters did not produce similar issues.
Below is the screenshot of my CMakeLists file and the screen shot of the error message. I did not make any change to the files after installing them using git.
cmake_minimum_required(VERSION 3.5)
project(pointcloud_to_laserscan)
find_package(ament_cmake REQUIRED)
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
tf2_sensor_msgs::tf2_sensor_msgs
)
rclcpp_components_register_node(laserscan_to_pointcloud
PLUGIN "pointcloud_to_laserscan::LaserScanToPointCloudNode"
EXECUTABLE laserscan_to_pointcloud_node)
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
tf2_sensor_msgs::tf2_sensor_msgs
)
Error Message
Starting >>> tutorial_interfaces
Starting >>> more_interfaces
Starting >>> my_package
Starting >>> pointcloud_to_laserscan
Starting >>> py_pubsub
Starting >>> python_parameters
Starting >>> turtlesim
Finished <<< more_interfaces [0.92s]
Finished <<< tutorial_interfaces [0.95s]
Starting >>> py_srvcli
--- stderr: pointcloud_to_laserscan
CMake Error at CMakeLists.txt:15 (add_library):
Target "laserscan_to_pointcloud" links to target
"rclcpp_components::component" but the target was not found. Perhaps a
find_package() call is missing for an IMPORTED target, or an ALIAS target
is missing?
CMake Error at CMakeLists.txt:15 (add_library):
Target "laserscan_to_pointcloud" links to target
"tf2_sensor_msgs::tf2_sensor_msgs" but the target was not found. Perhaps a
find_package() call is missing for an IMPORTED target, or an ALIAS target
is missing?
CMake Error at CMakeLists.txt:36 (add_library):
Target "pointcloud_to_laserscan" links to target
"rclcpp_components::component" but the target was not found. Perhaps a
find_package() call is missing for an IMPORTED target, or an ALIAS target
is missing?
CMake Error at CMakeLists.txt:36 (add_library):
Target "pointcloud_to_laserscan" links to target
"tf2_sensor_msgs::tf2_sensor_msgs" but the target was not found. Perhaps a
find_package() call is missing for an IMPORTED target, or an ALIAS target
is missing?
CMake Generate step failed. Build files cannot be regenerated correctly.
---
Failed <<< pointcloud_to_laserscan [1.40s, exited with code 1]
Aborted <<< turtlesim [1.37s]
Aborted <<< my_package [1.48s]
Aborted <<< py_pubsub [1.46s]
Aborted <<< python_parameters [1.46s]
Aborted <<< py_srvcli [0.63s]
Summary: 2 packages finished [1.76s]
1 package failed: pointcloud_to_laserscan
5 packages aborted: my_package py_pubsub py_srvcli python_parameters turtlesim
1 package had stderr output: pointcloud_to_laserscan
Thank you!
Asked by Delurion on 2022-09-01 00:16:54 UTC
Comments
I don't see a call to
ament_package()
in your CMakeLists.txt file. See: https://docs.ros.org/en/humble/How-To-Guides/Ament-CMake-Documentation.htmlAsked by clyde on 2022-12-01 13:37:49 UTC