title: How should CMakeLists.txt be written for ROS Groovy with PCL-1.6 integration
body: <p>I am asking here since answers.ros.org is hanging when posting... </p>
  
  <p>we are currently compiling a <em>PCL-1.6</em> software using <em>catkin</em> build system on 64-bit Ubuntu Linux 12.10 Quantal Quetzal. We are using <em>ROS Groovy</em> installed in the default path (Groovy and Hydro installed on the same system, Groovy workspace sourced while working now on groovy). </p>
  
  <p>We have been referring to wiki tutorias of ros (cannot link with my karma here) to draft a CMakeLists.txt setup for the project. Since the tutorial only states 2 lines about CMakeLists.txt and recommends using the default template we are asking for guidance here.</p>
  
  <p>The project is using a PCL software that supposedly should run in a ROS node sending data to the network. We have the original implementation in PCL-1.7 but with minimal modifications it runs on PCL-1.6, too, and now we are integrating it into ROS.</p>
  
  <p>We have added ROS required headers in the code, and ros::init, and ros::NodeHandle, but what else is absolutely required for the ROS node to run PCL-1.6? </p>
  
  <p>To make things not easier the least, OpenCV and BOOST are being used, too! (They are absolutely amazing libraries, when they work)</p>
  
  <p>Currently, a problem is: a warning about conflicting libraries</p>
  
  <pre><code>/usr/bin/ld: warning: libpcl_sample_consensus.so.1.6, needed by&gt;
  opt/ros/groovy/lib/libpcl_filters.so, may conflict with &gt; libpcl_sample_consensus.so.1.7
  /usr/bin/ld: warning: libpcl_io.so.1.6, needed by /opt/ros/groovy/lib/libpcl_visualization.so, may conflict with libpcl_io.so.1.7
  /usr/bin/ld: warning: libpcl_common.so.1.7, needed by /usr/lib/gcc/x86_64-linux-gnu/4.7/../../../../lib/libpcl_sample_consensus.so, may conflict with libpcl_common.so.1.6
  </code></pre>
  
  <p>even though no paths with pcl-1.7 are provided to catkin. I did create the package with pcl-1.7 dependency, but long since has removed dependency of pcl-1.7 from CMakeLists.txt, package.xml, and did catkin_make clean (does this not remove the dependency from all cmake files?).</p>
  
  <p>My question is how should I change my CMakeLists.txt setup to solve this linking error? Ultimately, the problem leads to segmentation faults in the program => PCL RANSAC segmentation filters crash.</p>
  
  <p>Here's the current CMakeLists.txt (in short) that successfully compiles and runs the project that we have written:</p>
  
  <h2><strong>CMakeLists.txt</strong></h2>
  
  <pre><code>cmake_minimum_required(VERSION 2.8.9 FATAL_ERROR)
  project(famous_emutanen_bv)
  set(famous_emutanen_bv_srcs src/disparity.cpp)
  
  find_package(catkin REQUIRED COMPONENTS
    geometry_msgs
  #  pcl
    pcl_ros
    roscpp
    rospy
    sensor_msgs
    std_msgs
  )
  find_package(PCL 1.6 REQUIRED)
  find_package(OpenCV 2.2 REQUIRED)
  find_package(Boost REQUIRED COMPONENTS system thread)
  
  catkin_package(
    INCLUDE_DIRS include
  #  LIBRARIES famous_emutanen_bv
  #  CATKIN_DEPENDS geometry_msgs pcl-1.7 pcl_ros roscpp rospy sensor_msgs std_msgs
  #  DEPENDS system_lib
  )
  
  include_directories(include
    ${catkin_INCLUDE_DIRS}
    ${PCL_INCLUDE_DIRS}
    ${OpenCV_INCLUDE_DIRS}
    ${Boost_INCLUDE_DIRS}
  )
  include_directories(/usr/include/vtk-5.8)
  
  link_directories(${PCL_LIBRARY_DIRS} ${OpenCV_LIBRARY_DIRS}) # 
  add_definitions(${PCL_DEFINITIONS} ${OpenCV_DEFINITIONS}) #
  add_executable(famous_emutanen_bv ${famous_emutanen_bv_srcs})
  
  target_link_libraries(famous_emutanen_bv ${catkin_LIBRARIES} ${PCL_LIBRARIES} ${OpenCV_LIBRARIES} ${Boost_LIBRARIES} libvtkCommon.so libvtkFiltering.so libvtkRendering.so) #
  </code></pre>
  
  <hr>
  
  <p>Should be added, this CMakeLists.txt compiles <strong>and runs</strong> against stand-alone PCL installation (1.6 or 1.7) nicely.
  and here is the <strong>package.xml</strong>:</p>
  
  <hr>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  &lt;package&gt;
    &lt;name&gt;famous_emutanen_bv&lt;/name&gt;
    &lt;version&gt;0.0.0&lt;/version&gt;
    &lt;description&gt;The famous_emutanen_bv package&lt;/description&gt;     
    &lt;maintainer email="emutanen@xx"&gt;emutanen&lt;/maintainer&gt;
    &lt;license&gt;GPLv3&lt;/license&gt;
    &lt;buildtool_depend&gt;catkin&lt;/buildtool_depend&gt;
    &lt;build_depend&gt;geometry_msgs&lt;/build_depend&gt;
    &lt;build_depend&gt;pcl_ros&lt;/build_depend&gt;
    &lt;build_depend&gt;roscpp&lt;/build_depend&gt;
    &lt;build_depend&gt;rospy&lt;/build_depend&gt;
    &lt;build_depend&gt;sensor_msgs&lt;/build_depend&gt;
    &lt;build_depend&gt;std_msgs&lt;/build_depend&gt;
    &lt;run_depend&gt;geometry_msgs&lt;/run_depend&gt;
    &lt;run_depend&gt;pcl_ros&lt;/run_depend&gt;
    &lt;run_depend&gt;roscpp&lt;/run_depend&gt;
    &lt;run_depend&gt;rospy&lt;/run_depend&gt;
    &lt;run_depend&gt;sensor_msgs&lt;/run_depend&gt;
    &lt;run_depend&gt;std_msgs&lt;/run_depend&gt;
    &lt;export&gt;
      &lt;!-- &lt;metapackage/&gt; --&gt;
    &lt;/export&gt;
  &lt;/package&gt;
  </code></pre>
  
  <hr>
  
  <p>I have tried to trace down the segfault with GDB and we can interestingly see that sample_consensus library changes in the middle of things from 1.6 to 1.7</p>
  
  <pre><code>(gdb) backtrace
  #0  0x00007ffff396caed in pcl::SampleConsensusModelCylinder&lt;pcl::PointXYZ, pcl::Normal&gt;::computeModelCoefficients(std::vector&lt;int, std::allocator&lt;int&gt; &gt; const&amp;, Eigen::Matrix&lt;float, -1, 1, 0, -1, 1&gt;&amp;) ()
     from /usr/lib/libpcl_sample_consensus.so.1.7
  #1  0x00007ffff4cb6166 in pcl::RandomSampleConsensus&lt;pcl::PointXYZ&gt;::computeModel(int) () from /opt/ros/groovy/lib/libpcl_segmentation.so.1.6
  #2  0x00007ffff4cafd1c in pcl::SACSegmentation&lt;pcl::PointXYZ&gt;::segment(pcl::PointIndices_&lt;std::allocator&lt;void&gt; &gt;&amp;, pcl::ModelCoefficients_&lt;std::allocator&lt;void&gt; &gt;&amp;) () from /opt/ros/groovy/lib/libpcl_segmentation.so.1.6
  #3  0x000000000049ac23 in famous::segmentCylinder(boost::shared_ptr&lt;pcl::PointCloud&lt;pcl::PointXYZ&gt; &gt;&amp;, boost::shared_ptr&lt;pcl::ModelCoefficients_&lt;std::allocator&lt;void&gt; &gt; &gt;) ()
  #4  0x00000000004a1164 in famous::updatePointCloud() ()
  #5  0x00000000004a6fa7 in main ()
  </code></pre>
  
  <p>What should we do with CMakeLists.txt in order to solve the problem?
  Hopefully someone can guide us in the right direction, while at it, happy holidays everyone! </p>