我项目中的一个可执行文件依赖于 boost
。 header 和库位于自定义目录中,比如 dirA 和 dirB。我已经包括
find_package(boost)
在 CMakeLists.txt
中,但它输出
-- Could NOT find Boost
当cmake ..
在工程目录下的build/
中执行时。
由于 CMakeLists.txt
是公共(public)项目的一部分,我不想在其中硬编码 dirA 和 dirB。有没有办法通过在本地更改某些内容来使 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/