2017-02-05 330 views
0

我試圖製作PCL示例項目。 here我用cmake構建。但是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) 

我有Ç提升:\ Program Files文件\ PCL 1.5.1 \的3rdParty \升壓,因爲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如下(我剛纔提到的代碼片段,涉及到提高)

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) 

任何幫助表示讚賞此事。

回答

0

嘗試設置升壓直接瓦爾如下:

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

使用在C進行圖形化的工具。 (直接硬編碼路徑會起作用,但這不是你想要做的,它打敗了CMake的目的)。

各種變量將顯示爲BOOST_ROOT,BOOST_DIR等。在圖形工具中,單擊,然後將該變量指向Boost目錄。根據CMake文件的具體設置,您可能需要使用它一段時間,直到它開心,但最終它應該找到Boost。 您必須正確安裝Boost,包括編譯非jeader組件,但我認爲已經被檢查過。