简体   繁体   English

CMake无法找到Boost

[英]Cmake unable to find Boost

I tried to make PCL example project. 我试图制作PCL示例项目。 here i used cmake to build. 在这里,我用cmake来构建。 But cmake gives an Error as below 但是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)

I have Boost in C:\\Program Files\\PCL 1.5.1\\3rdParty\\Boost , since cmake couldn't find in default location i think it might throw an error. 我在C:\\ Program Files \\ PCL 1.5.1 \\ 3rdParty \\ Boost中具有Boost功能 ,因为cmake在默认位置找不到,我认为它可能会引发错误。 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. macro(find_boost)之前,但也抛出相同的错误。 please find my PCLConfig.cmake below (i have mentioned the code snippet that relates to 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)

Any help is appreciated to this matter. 感谢您对此事的帮助。

try setting the boost vars directly as following : 尝试直接设置boost var,如下所示:

    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)

Use the graphical tool in CMake. 使用CMake中的图形工具。 (Hardcoding paths directly will work, but it's not what you want to do, it defeats the purpose of CMake). (直接使用硬编码路径即可,但这不是您想要的,它违背了CMake的目的)。

Various variables will appear like BOOST_ROOT, BOOST_DIR and so on. 各种变量将出现,例如BOOST_ROOT,BOOST_DIR等。 In the graphical tool, click and then point the variable to the Boost directories. 在图形工具中,单击,然后将变量指向Boost目录。 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. 取决于CMake文件的确切设置方式,您可能需要一段时间才能使用它,直到满意为止,但最终它应该找到Boost。 You must have installed Boost correctly, including compiling the non-jeader components, but I assume that has been checked already. 您必须已经正确安装了Boost,包括编译了非Jeader组件,但是我认为已经检查过了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM