繁体   English   中英

Boost_LIBRARIES未定义

[英]Boost_LIBRARIES not defined

我正在尝试编译FreeLing,它使用CMake来检测Boost。 这是负责它的代码:

  find_package(Boost COMPONENTS regex filesystem thread program_options REQUIRED)

找到以下组件(根据CMake生成的输出):

-- Found Boost 1.70.0 at /home/ambs/usr/lib/cmake/Boost-1.70.0
--   Requested configuration: QUIET REQUIRED COMPONENTS regex;filesystem;thread;program_options
-- Found boost_headers 1.70.0 at /home/ambs/usr/lib/cmake/boost_headers-1.70.0
-- Found boost_regex 1.70.0 at /home/ambs/usr/lib/cmake/boost_regex-1.70.0
--   libboost_regex.so.1.70.0
-- Adding boost_regex dependencies: headers
-- Found boost_filesystem 1.70.0 at /home/ambs/usr/lib/cmake/boost_filesystem-1.70.0
--   libboost_filesystem.so.1.70.0
-- Adding boost_filesystem dependencies: headers
-- Found boost_thread 1.70.0 at /home/ambs/usr/lib/cmake/boost_thread-1.70.0
--   libboost_thread.so.1.70.0
-- Adding boost_thread dependencies: headers
-- Found boost_program_options 1.70.0 at /home/ambs/usr/lib/cmake/boost_program_options-1.70.0
--   libboost_program_options.so.1.70.0
-- Adding boost_program_options dependencies: headers
-- Boost  found.
-- Found Boost components:
   regex;filesystem;thread;program_options

但是,似乎从未设置Boost_LIBRARIES 我尝试了这个:

  find_package(Boost COMPONENTS regex filesystem thread program_options REQUIRED)
  message(STATUS "Boost_LIBRARIES=" ${Boost_LIBRARIES})

并且它总是输出一个空字符串。

作为参考,我有CMake版本3.14.3和Boost版本1.70.0。

线

在/home/ambs/usr/lib/cmake/Boost-1.70.0处找到Boost 1.70.0

意味着CMake模块FindBoost.cmake不会使用其自己的方法检测Boost库和标头,而是诉诸于位于日志显示的目录中的BoostConfig.cmake脚本。

FindBoost.cmake模块的文档以这种方式进行注释:

该模块查找标头和请求的组件库,或“ Boost CMake”版本提供的C​​Make软件包配置文件。 对于后一种情况,请跳到下面的“ Boost CMake”部分。 对于前一种情况,结果报告为变量:

简而言之,使用BoostConfig.cmake脚本意味着它设置了自己的变量或目标,而FindBoost.cmake文档中描述的变量或目标无效。

最有可能的是,“ Config”文件以与FindBoost.cmake文档中所述相同的方式设置IMPORTED目标 ,即Boost::regexBoost::filesystem等。


如果要禁用使用BoostConfig.cmake并强制FindBoost.cmake其文档中所述的行为,请设置Boost_NO_BOOST_CMAKE变量。 例如,当调用cmake

cmake -DBoost_NO_BOOST_CMAKE=ON <other-options>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM