c++ - 如何使 FindBoost.cmake 工作?

标签 c++ boost cmake

我项目中的一个可执行文件依赖于 boost。 header 和库位于自定义目录中,比如 dirAdirB。我已经包括

find_package(boost)

CMakeLists.txt 中,但它输出

-- Could NOT find Boost

cmake ..在工程目录下的build/中执行时。

由于 CMakeLists.txt 是公共(public)项目的一部分,我不想在其中硬编码 dirAdirB。有没有办法通过在本地更改某些内容来使 FindBoost.cmake 工作?说修改FindBoost.cmake,或者设置一些环境变量。

最佳答案

查看 documentation for FindBoost :

BOOST_ROOT - Preferred installation prefix

[...]

Note that some hint names start in upper-case "BOOST". One may specify these as environment variables if they are not specified as CMake variables or cache entries.

BOOST_ROOT 环境变量指向您机器上的 Boost 目录,CMake 应该能够自动找到它。

关于c++ - 如何使 FindBoost.cmake 工作?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21135721/

相关文章:

c++ - 将 const-string 分配给常量大小的 char 数组,未使用的数组索引会发生什么?

c++ - CMake可以生成配置文件吗?

linux - CMake:不要为链接中使用的单个库设置 rpath

c++ - CMake AUTOMOC 文件位于不同的文件夹中

c++ - 维护一个 std::set<boost::shared_ptr>

c++ - 纹理图像未正确映射

c++ - 用零 eigen3 c++ 替换所有负元素

c++ - 如何构建 Boost::program_options

c++ - g++:使用 ZIP 文件作为输入

c++ - CMake 链接 Boost : cannot find -lboost_program_options