Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
705 views
in Technique[技术] by (71.8m points)

c++ - Cmake unable to find Boost

I tried to make PCL example project.here i used cmake to build. But cmake gives an Error as below

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)

I have Boost in C:Program FilesPCL 1.5.13rdPartyBoost , since cmake couldn't find in default location i think it might throw an error. To get rid of that error i add

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

before the macro(find_boost) But also throw the same Error. please find my PCLConfig.cmake below (i have mentioned the code snippet that relates to 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)

Any help is appreciated to this matter.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Use the graphical tool in CMake. (Hardcoding paths directly will work, but it's not what you want to do, it defeats the purpose of CMake).

Various variables will appear like BOOST_ROOT, BOOST_DIR and so on. In the graphical tool, click and then point the variable to the Boost directories. Depending on exactly how the CMake file has been set up you might have to play with it for a while until it is happy, but eventually it should find Boost. You must have installed Boost correctly, including compiling the non-jeader components, but I assume that has been checked already.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...