问题描述
我正在尝试使用从源代码构建的Boost版本在CentOS 5上构建CMake项目。我已经在/tmp/boost/boost_1_74_0
中安装了Boost 1.74.0。在我的CMakeLists.txt
中,我尝试使用find_package(Boost 1.72 required COMPONENTS graph)
查找此安装。我还将-DBOOST_ROOT=/tmp/boost/boost_1_74_0
传递给cmake
。
表面上对find_package
的调用成功。但是,Boost_INCLUDE_DIR
随后仍设置为Boost_INCLUDE_DIR-NOTFOUND
。我不明白为什么或如何发生,该项目建立在我通过软件包管理器安装了Boost的其他几个系统上。即使我将/tmp/boost/boost_1_74_0/boost
符号链接或复制到/usr/include
,CMake仍无法设置Boost_INCLUDE_DIR
。这里可能是什么问题?
当我还指定-DBoost_DEBUG=ON
时,这就是CMake的输出:
-- Finding boost...
-- Found Boost 1.74.0 at /usr/lib/cmake/Boost-1.74.0
-- Requested configuration: QUIET required COMPONENTS graph
-- BoostConfig: find_package(boost_headers 1.74.0 EXACT CONfig required QUIET HINTS /usr/lib/cmake)
-- Found boost_headers 1.74.0 at /usr/lib/cmake/boost_headers-1.74.0
-- BoostConfig: find_package(boost_graph 1.74.0 EXACT CONfig required QUIET HINTS /usr/lib/cmake)
-- Found boost_graph 1.74.0 at /usr/lib/cmake/boost_graph-1.74.0
-- Boost toolset is gcc8 (GNU 8.3.1)
-- Scanning /usr/lib/cmake/boost_graph-1.74.0/libboost_graph-variant*.cmake
-- Including /usr/lib/cmake/boost_graph-1.74.0/libboost_graph-variant-shared.cmake
-- [x] libboost_graph.so.1.74.0
-- Including /usr/lib/cmake/boost_graph-1.74.0/libboost_graph-variant-static.cmake
-- [ ] libboost_graph.a
-- Adding boost_graph dependencies: regexheaders
-- Found boost_regex 1.74.0 at /usr/lib/cmake/boost_regex-1.74.0
-- Boost toolset is gcc8 (GNU 8.3.1)
-- Scanning /usr/lib/cmake/boost_regex-1.74.0/libboost_regex-variant*.cmake
-- Including /usr/lib/cmake/boost_regex-1.74.0/libboost_regex-variant-shared.cmake
-- [x] libboost_regex.so.1.74.0
-- Including /usr/lib/cmake/boost_regex-1.74.0/libboost_regex-variant-static.cmake
-- [ ] libboost_regex.a
-- Adding boost_regex dependencies: headers
-- Configuring done
CMake Error: The following variables are used in this project,but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
Boost_INCLUDE_DIR
解决方法
Boost_INCLUDE_DIR
是一个变量,可以将其指定为FindBoost.cmake模块的输入,以查找Boost安装。您更可能对FindBoost.cmake模块填充的Boost_INCLUDE_DIRS
变量(请注意结尾的S
)感兴趣。有关更多信息,请参见documentation。