3D【13】在clion中使用PCL

主要是将PCL加入CMakeList.txt中去,不过我还是遇到了一些问题。比如说cmake没有真正的将pcl的头文件目录取进去。
从源码安装好PCL-1.8后,利用find_package(PCL REQUIRED)寻找PCL包,发现能找到,但是include_directories(PCL_INCLUDE_DIRS)无法添加头文件,因此我就自己手动添加。具体是CMakelist.txt如下:

cmake_minimum_required(VERSION 2.8)
project(pclRegister)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
if(NOT PCL_INCLUDE_DIRS)
    message("find pcl")
    find_package(PCL   REQUIRED)
endif(NOT PCL_INCLUDE_DIRS)
#include_directories(PCL_INCLUDE_DIRS) #无效

include_directories(/usr/include/eigen3)#手动添加
include_directories(/usr/local/include/pcl-1.8) #手动添加
link_directories(${PCL_LIBRARY_DIRS})
add_definitions(${PCL_DEFINITIONS})
set(SOURCE_FILES main.cpp)
add_executable(pclRegister ${SOURCE_FILES})

#要使用哪些功能模块就需要链接,不然会提示未定义的引用
target_link_libraries(pclRegister ${PCL_COMMON_LIBRARIES} ${PCL_IO_LIBRARIES} ${PCL_VISUALIZATION_LIBRARIES} ${PCL_RESISTRATION_LIBRARIES} ${PCL_FILTERS_LIBRARIES} ${PCL_FEATURES_LIBRARIES})

你可能感兴趣的:(3d)