Boost_LIBRARIES未定义 [英] Boost_LIBRARIES not defined

查看:715
本文介绍了Boost_LIBRARIES未定义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I am trying to compile FreeLing, that uses CMake to detect Boost. This is the code responsible for it:

  find_package(Boost COMPONENTS regex filesystem thread program_options REQUIRED)

找到这些组件(根据CMake生成的输出):

These components are found (accordingly to the output generated by 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.我试过了:

Nevertheless, it looks like Boost_LIBRARIES is never set. I tried this:

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

,它总是输出一个空字符串.

and it output always a empty string.

供参考,我有CMake版本3.14.3和Boost版本1.70.0.

For reference, I have CMake version 3.14.3, and Boost version 1.70.0.

推荐答案

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

Found Boost 1.70.0 at /home/ambs/usr/lib/cmake/Boost-1.70.0

表示CMake模块 FindBoost.cmake 不使用自己的方法检测Boost库和标头,但诉诸日志中显示的目录中的BoostConfig.cmake脚本.

means that CMake module FindBoost.cmake doesn't detects Boost libraries and headers using its own methods but resorts to BoostConfig.cmake script, located in the directory shown in the log.

FindBoost.cmake模块的文档注释方式如下:

Documentation for FindBoost.cmake module notes such way:

此模块查找标头和请求的组件库或CMake 由"Boost CMake"版本提供的软件包配置文件.为了 对于后一种情况,请跳到下面的"Boost CMake"部分.对于前者 案例结果以变量报告:

This module finds headers and requested component libraries OR a CMake package configuration file provided by a "Boost CMake" build. For the latter case skip to the "Boost CMake" section below. For the former case results are reported in variables:

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

In short, using BoostConfig.cmake script means that it sets its own variables or targets, and ones described in the documentation for FindBoost.cmake are not valid.

很有可能,配置"文件以与FindBoost.cmake文档中所述相同的方式设置导入的目标,即Boost::regexBoost::filesystem等.

Most likely, the "Config" file sets IMPORTED targets in the same manner, as described in FindBoost.cmake documentation, that is Boost::regex, Boost::filesystem and so on.

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

If you want to disable using BoostConfig.cmake and force FindBoost.cmake to behave as described in its documentation, set Boost_NO_BOOST_CMAKE variable. E.g., when call cmake:

cmake -DBoost_NO_BOOST_CMAKE=ON <other-options>

这篇关于Boost_LIBRARIES未定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆