Please help with my CMakeLists.txt. Conflicting packages unable to build.
Hello! I am really confused on how to construct an appropriate CMakeLists.txt. I am trying to create a package and I was able to create all of the necessary nodes and they work seperately, but when I try to build it all together, I get a lot of errors.
The two packages causing problems are pcl_ros and ocs2_ros_interfaces (https://github.com/leggedrobotics/ocs2).
I am using ros noetic. Below is my CMakeLists.txt
cmake_minimum_required(VERSION 3.0.2)
project(sara_arm)
## Compile as C++11, supported in ROS Kinetic and newer
# add_compile_options(-std=c++11)
## Find catkin macros and libraries
## if COMPONENTS list like find_package(catkin REQUIRED COMPONENTS xyz)
## is used, also find other catkin packages
find_package(catkin REQUIRED COMPONENTS
actionlib
actionlib_msgs
pcl_msgs
pcl_ros
moveit_core
moveit_ros_planning
moveit_ros_planning_interface
sensor_msgs
tf2
tf2_ros
kinova_msgs
moveit_visual_tools
tf2_eigen
ocs2_ros_interfaces
)
add_service_files(
FILES
image_to_cloud_point.srv
)
generate_messages(
DEPENDENCIES
geometry_msgs # Or other packages containing msgs
sensor_msgs
)
include_directories(
include
${catkin_INCLUDE_DIRS}
)
add_executable(ocs2_sara src/ocs2_sara.cpp)
target_link_libraries(ocs2_sara ${catkin_LIBRARIES})
add_executable(pcp_sara src/pcp_sara.cpp)
target_link_libraries(pcp_sara ${catkin_LIBRARIES})
add_executable(sara_arm src/sara_arm.cpp)
target_link_libraries(sara_arm ${catkin_LIBRARIES})
The errors that pop up are referencing a lot of issues with pcl.
- If I comment out the pcp_sara add_executable and target_link_libraries calls, it builds fine (but I cannot use that node, obviously)
- If I comment out the ocs2_sara add_executable and target_link_libraries calls, it does not build and tells me I have tons of errors with pcl, similar to if I leave it uncommented
- If I comment out the ocs2_sara add_executable and target_link_libraries calls AND the ocs2_ros_interfaces from the find_pakage() call, it builds fine, but I cannot use the ocs2_sara node
I would appreciate any help, I am sure I am missing something (perhaps a catkin_package() call) but since everything works independently, I am not sure what to do to make sure they work together. Is there something I can look into in the ocs2_ros_interfaces that might be causing issues?
NOTE: ocs2_ros_interfaces is cloned to my catkin_ws, while pcl (and all the other packages listed) are installed via sudo apt-get install.