我正在尝试使用 CMakeLists.txt 文件使用 QtCreator 编译 PCL 示例。 FindPCL.cmake 文件(从此处获取:Last of the attached files)与源文件位于同一目录中。
我的 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.txt 中的PCL_DIR
var设置为PCL安装目录,如PCL教程Using PCL in your own project中所述,位于底部。< / p>
最后,我得到的错误是:
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_MODULE_PATH
指向 CMake 二进制文件的目录。是吗?
PS2:我正在使用MingW编译器。
PS3:SO是Windows 7 64位。
答案 0 :(得分:0)
您应该将CMAKE_MODULE_PATH
设置为包含FindPCL.cmake
的目录。如果这个目录是模块的标准CMake目录(share/cmake/Modules
),那么根本不需要它。
因此,将CMAKE_MODULE_PATH
设置为bin/
目录是错误的。