0
votes

I'm trying to compile a PCL example with QtCreator, using a CMakeLists.txt file. The FindPCL.cmake file (got it from here: Last of the attached files) is in the same directory of the source files.

My CMakeLists.txt file is:

cmake_minimum_required(VERSION 2.6 FATAL_ERROR)
project(pclcmake)
list(APPEND CMAKE_MODULE_PATH "C:/CMake2.8/bin")
set(PCL_ROOT "E:/LIBRERIAS/PCL1.5.1")
set(PCL_DIR "E:/LIBRERIAS/PCL1.5.1/cmake")
find_package(PCL 1.5.1 REQUIRED COMPONENTS common octree io)
include_directories(${PCL_INCLUDE_DIRS})
link_directories(${PCL_LIBRARY_DIRS})
add_definitions(${PCL_DEFINITIONS})
add_executable(pcl_cmake main.cpp)
target_link_libraries(pcl_cmake ${PCL_COMMON_LIBRARIES} ${PCL_OCTREE_LIBRARIES} ${PCL_IO_LIBRARIES})

The code I'm trying to compile is this:

#include <pcl/io/pcd_io.h>
#include <pcl/point_types.h>

#include <iostream>

int main(int argc, char* argv[]) {
  pcl::PointCloud<pcl::PointXYZ>::Ptr cloud (new pcl::PointCloud<pcl::PointXYZ>);

  if (pcl::io::loadPCDFile<pcl::PointXYZ> ("test_pcd.pcd", *cloud) == -1) //* load the file
  {
     std::cout << "Nope\n";
     return (-1);
  }
  std::cout << "Loaded " << cloud->width * cloud->height << " data points from test_pcd.pcd with the following fields: " << std::endl;
  for (size_t i = 0; i < cloud->points.size (); ++i)
     std::cout << "    " << cloud->points[i].x << " "    << cloud->points[i].y << " "    << cloud->points[i].z << std::endl;

  return (0);
}

I have also set the PCL_DIR var in my CMakeLists.txt point to the PCL install dir, as said in the PCL tutorial Using PCL in your own project, at the bottom.

Finally, the error I get is:

CMake Error at CMakeLists.txt:6 (find_package):
  By not providing "FindPCL.cmake" in CMAKE_MODULE_PATH this project has
  asked CMake to find a package configuration file provided by "PCL", but
  CMake did not find one.

  Could not find a package configuration file provided by "PCL" (requested
  version 1.5.1) with any of the following names:

    PCLConfig.cmake
    pcl-config.cmake

  Add the installation prefix of "PCL" to CMAKE_PREFIX_PATH or set "PCL_DIR"
  to a directory containing one of the above files.  If "PCL" provides a
  separate development package or SDK, be sure it has been installed.

Any idea? Thanks in advance.

PS: In the CMakeLists file, I point CMAKE_MODULE_PATH to the directory of the CMake binary. Is that right?

PS2: I'm using the MingW compiler.

PS3: The SO is Windows 7 64 bits.

1
Whoooooooooooops, forgot that!!. I'll edit the post!. Thanks!Adri C.S.
Also, the compiler I'm using is MingW. I already added that info into the post.Adri C.S.
Are you get the correct answer?Snail
@YeYeahPing sorry?Adri C.S.
I encountered this problem as well.Snail

1 Answers

0
votes

You should set CMAKE_MODULE_PATH to the directory, which contains FindPCL.cmake. If this dir is standard CMake dir for modules (share/cmake/Modules), you don't need this at all.

Setting CMAKE_MODULE_PATH to the bin/ dir is wrong, therefore.