CMake无法找到Boost [英] Cmake unable to find Boost

查看:1071
本文介绍了CMake无法找到Boost的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图制作PCL示例项目.这里 cmake建立.但是cmake给出如下错误

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)

我在 C:\ Program Files \ PCL 1.5.1 \ 3rdParty \ Boost 中具有Boost功能,因为cmake在默认位置找不到,我认为这可能会引发错误.为了消除该错误,我添加了

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

之前的

,但还会抛出相同的错误.请在下面找到我的PCLConfig.cmake(我已经提到了与boost相关的代码段)

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)

感谢您对此事的帮助.

推荐答案

在CMake中使用图形工具. (直接使用硬编码路径即可,但这不是您想要的,它违背了CMake的目的.)

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

各种变量将显示为BOOST_ROOT,BOOST_DIR等.在图形工具中,单击,然后将变量指向Boost目录.取决于CMake文件的确切设置方式,您可能需要一段时间才能使用它,直到满意为止,但最终它应该找到Boost. 您必须已经正确安装了Boost,包括编译了非Jeader组件,但是我认为已经检查过了.

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.

这篇关于CMake无法找到Boost的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆