首页 > 解决方案 > CMake 发现 Boost 但未设置 Boost_INCLUDE_DIR

问题描述

我正在尝试使用内置源代码版本的 Boost 在 CentOS 5 上构建 CMake 项目。我已经在/tmp/boost/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。这里可能是什么问题?

这是我还指定时 CMake 输出的内容-DBoost_DEBUG=ON

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

标签: boostcmakecentos

解决方案


Boost_INCLUDE_DIR是一个变量,可以指定为 FindBoost.cmake 模块的输入以查找 Boost 安装。您更有可能对FindBoost.cmake 模块填充的Boost_INCLUDE_DIRS变量(注意尾随)感兴趣。S有关详细信息,请参阅文档


推荐阅读