强制cmake使用特定的boost文件夹

时间:2016-05-20 16:25:48

标签: c++ boost cmake

我在指定要使用的提升版本时尝试编译我的项目。

cmake文件包含以下内容

  message("before boost include_dir "${Boost_INCLUDE_DIR})
  message("before boost boost_root "${BOOST_ROOT})
  message("before boost boostroot "${BOOSTROOT})
  message("before boost includedir "${BOOST_INCLUDEDIR})
  message("before boost librarydir "${BOOST_LIBRARYDIR})

  set(Boost_USE_STATIC_LIBS ON)
  find_package(Boost COMPONENTS program_options regex REQUIRED)

  message("after boost include_dir "${Boost_INCLUDE_DIR})
  message("after boost boost_root "${BOOST_ROOT})
  message("after boost boostroot "${BOOSTROOT})
  message("after boost includedir "${BOOST_INCLUDEDIR})
  message("after boost librarydir "${BOOST_LIBRARYDIR})

当我运行cmake

build> cmake  -DBoost_NO_SYSTEM_PATHS=TRUE -DBOOST_ROOT=/opt/cluster/v1/c++_lib/boost_gcc4.8/1.52.0 -DBoost_DEBUG=ON ..

我进入输出

before boost include_dir 
before boost boost_root /opt/cluster/v1/c++_lib/boost_gcc4.8/1.52.0
before boost boostroot 
before boost includedir 
before boost librarydir 
Boost  found.
Found Boost components:
   program_options;regex
after boost include_dir /usr/include
after boost boost_root /opt/cluster/v1/c++_lib/boost_gcc4.8/1.52.0
after boost boostroot 
after boost includedir 
after boost librarydir

正如你所看到的那样,包括发现的dir不是我的:

after boost include_dir /usr/include

我无法调试因为我的变量被忽略了,因为在输出结束时我有这个:

CMake Warning:
  Manually-specified variables were not used by the project:

    Boost_DEBUG

这是我的cmake版本

build> cmake --version
cmake version 3.0.0

1)我如何强制cmake使用我的助推器?

2)为什么忽略-DBoost_DEBUG = ON?

0 个答案:

没有答案