我试着制作PCL示例项目。这里我用cmake来构建。但是cmake给出了如下错误
Could NOT find Boost
CMake Error at C:/Program Files/PCL 1.5.1/cmake/PCLConfig.cmake:38 (message):
common is required but boost was not found
Call Stack (most recent call first):
C:/Program Files/PCL 1.5.1/cmake/PCLConfig.cmake:346 (pcl_report_not_found)
C:/Program Files/PCL 1.5.1/cmake/PCLConfig.cmake:491 (find_external_library)
CMakeLists.txt:5 (find_package)
我在C:\Program \PCL1.5.1\3 3rdParty\ Boost 中有Boost,因为cmake在默认位置找不到,我认为它可能会引发错误。为了消除这个错误,我添加了
SET(CMAKE_INCLUDE_PATH ${CMAKE_INCLUDE_PATH} "C:/Program Files/PCL 1.5.1/3rdParty/Boost/include")
SET(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} "C:/Program Files/PCL 1.5.1/3rdParty/Boost/lib")
在macro(find_boost)
之前,还抛出相同的错误。请在下面找到我的PCLConfig.cmake (我已经提到了与boost相关的代码片段)
SET(CMAKE_INCLUDE_PATH ${CMAKE_INCLUDE_PATH} "C:/Program Files/PCL 1.5.1/3rdParty/Boost/include")
SET(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} "C:/Program Files/PCL 1.5.1/3rdParty/Boost/lib")
macro(find_boost)
if(PCL_ALL_IN_ONE_INSTALLER)
set(BOOST_ROOT "${PCL_ROOT}/3rdParty/Boost")
elseif(NOT BOOST_INCLUDEDIR)
set(BOOST_INCLUDEDIR "d:/git/SuperBuild/build/CMakeExternal/Install/Boost/include")
endif(PCL_ALL_IN_ONE_INSTALLER)
# use static Boost in Windows
if(WIN32)
set(Boost_USE_STATIC_LIBS ON)
set(Boost_USE_STATIC ON)
endif(WIN32)
if(${CMAKE_VERSION} VERSION_LESS 2.8.5)
SET(Boost_ADDITIONAL_VERSIONS "1.43" "1.43.0" "1.44" "1.44.0" "1.45" "1.45.0" "1.46.1" "1.46.0" "1.46" "1.47" "1.47.0")
else(${CMAKE_VERSION} VERSION_LESS 2.8.5)
SET(Boost_ADDITIONAL_VERSIONS "1.47" "1.47.0")
endif(${CMAKE_VERSION} VERSION_LESS 2.8.5)
# Disable the config mode of find_package(Boost)
set(Boost_NO_BOOST_CMAKE ON)
find_package(Boost 1.40.0 ${QUIET_} COMPONENTS system filesystem thread date_time iostreams)
set(BOOST_FOUND ${Boost_FOUND})
set(BOOST_INCLUDE_DIRS "${Boost_INCLUDE_DIR}")
set(BOOST_LIBRARY_DIRS "${Boost_LIBRARY_DIRS}")
set(BOOST_LIBRARIES ${Boost_LIBRARIES})
if(WIN32)
set(BOOST_DEFINITIONS ${BOOST_DEFINITIONS} -DBOOST_ALL_NO_LIB)
endif(WIN32)
endmacro(find_boost)
在这件事上,任何帮助都是值得感谢的。
发布于 2017-02-07 16:05:41
尝试按以下方式直接设置boost vars:
macro(find_boost)
if(PCL_ALL_IN_ONE_INSTALLER)
set(BOOST_ROOT "${PCL_ROOT}/3rdParty/Boost")
elseif(NOT BOOST_INCLUDEDIR)
set(BOOST_INCLUDEDIR ""C:/Program Files/PCL 1.5.1/3rdParty/Boost/include")
set(BOOST_INCLUDEDIR ""C:/Program Files/PCL 1.5.1/3rdParty/Boost/include")
set(Boost_LIBRARY_DIR "C:/Program Files/PCL 1.5.1/3rdParty/Boost/lib")
endif(PCL_ALL_IN_ONE_INSTALLER)
# use static Boost in Windows
if(WIN32)
set(Boost_USE_STATIC_LIBS ON)
set(Boost_USE_STATIC ON)
endif(WIN32)
if(${CMAKE_VERSION} VERSION_LESS 2.8.5)
SET(Boost_ADDITIONAL_VERSIONS "1.43" "1.43.0" "1.44" "1.44.0" "1.45" "1.45.0" "1.46.1" "1.46.0" "1.46" "1.47" "1.47.0")
else(${CMAKE_VERSION} VERSION_LESS 2.8.5)
SET(Boost_ADDITIONAL_VERSIONS "1.47" "1.47.0")
endif(${CMAKE_VERSION} VERSION_LESS 2.8.5)
# Disable the config mode of find_package(Boost)
set(Boost_NO_BOOST_CMAKE ON)
find_package(Boost 1.40.0 ${QUIET_} COMPONENTS system filesystem thread date_time iostreams)
set(BOOST_FOUND ${Boost_FOUND})
set(BOOST_INCLUDE_DIRS "${Boost_INCLUDE_DIR}")
set(BOOST_LIBRARY_DIRS "${Boost_LIBRARY_DIRS}")
set(BOOST_LIBRARIES ${Boost_LIBRARIES})
if(WIN32)
set(BOOST_DEFINITIONS ${BOOST_DEFINITIONS} -DBOOST_ALL_NO_LIB)
endif(WIN32)
endmacro(find_boost)
https://stackoverflow.com/questions/42050193
复制相似问题