0

我正在尝试使用CMakeLists.txt文件使用QtCreator编译PCL示例。FindPCL.cmake文件(从此处获取:最后一个附加文件)位于源文件的同一目录中。

我的CMakeLists.txt文件是:

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})

我要编译的代码是这样的:

#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);
}

我还在我的CMakeLists.txtPCL_DIR中将var设置为指向 PCL 安装目录,如底部的 PCL 教程Using PCL in your own project中所述。

最后,我得到的错误是:

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.

任何想法?提前致谢。

PS:在CMakeLists文件中,我指向CMake二进制文件CMAKE_MODULE_PATH的目录。那正确吗?

PS2:我正在使用 MingW 编译器。

PS3:SO 是 Windows 7 64 位。

4

1 回答 1

0

您应该设置CMAKE_MODULE_PATH为包含FindPCL.cmake. 如果此目录是模块 ( share/cmake/Modules) 的标准 CMake 目录,则您根本不需要它。

因此,设置CMAKE_MODULE_PATHbin/目录是错误的。

于 2012-11-29T11:28:31.927 回答