# Compiling PCL from source for multiple ros nodes (pcl_ros_gencfg error)

I had this exact problem when building PCL from source (in order to activate Cuda support) and the answer in that link works perfectly.

However, as soon as I introduce one additional ros node (two or more) and run: cd $ROS_WS && catkin_make && source devel/setup.bash Unfortunately there is another issue: add_custom_target cannot create target "pcl_ros_gencfg" because another target with the same name already exists. The existing target is a custom target created in source directory "/opt/ros_ws/src/other_ros_node_requiring_pcl". See documentation for policy CMP0002 for more details. And if I simply do: rm -rf$ROS_WS/build and then run the catkin_make command above again it works. But each time I build I must again remove the build dir, so this feels very hacky.

I've tried googling this error, but the answer I've found seems to have no impact. It's strange this works when I am only compiling PCL alongside one other ros node that depends on it.

I have a very straight forward setup (same for both ros nodes depending on PCL):

CMakeLists.txt

find_package(PCL REQUIRED COMPONENTS common io)
include_directories(${PCL_INCLUDE_DIRS}) link_directories(${PCL_LIBRARY_DIRS})
add_definitions(${PCL_DEFINITIONS}) find_package(catkin REQUIRED COMPONENTS roscpp std_msgs pcl_ros pcl_conversions ) target_link_libraries(${PROJECT_NAME}
${catkin_LIBRARIES}${PCL_LIBRARIES}
)


package.xml

<?xml version="1.0"?>
<package format="2">
<name>name</name>
<version>0.0.0</version>
<description>PCL tests</description>

<author>author</author>
<maintainer email="me@me.com">me</maintainer>

<buildtool_depend>catkin</buildtool_depend>

<depend>roscpp</depend>
<depend>std_msgs</depend>
<depend>pcl_conversions</depend>
<depend>pcl_ros</depend>

<test_depend>rostest</test_depend>
</package>


https://github.com/PointCloudLibrary/pcl/archive/pcl-1.11.1.tar.gz
https://github.com/ros-perception/perception_pcl/archive/1.7.2.tar.gz