CMake 找到 Boost 但导入的目标不适用于 Boost 版本 [英] CMake finds Boost but the imported targets not available for Boost version

查看:47
本文介绍了CMake 找到 Boost 但导入的目标不适用于 Boost 版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 CMake 来查找 Boost.找到了 Boost,但 CMake 出错了

I use CMake to find Boost. Boost is found, but CMake errors out with

导入的目标不适用于 Boost 版本

Imported targets not available for Boost version

请参阅下面的完整错误(来自 macOS).我做错了什么?

See the complete error (from macOS) below. What am I doing wrong?

CMake Warning at /Applications/CMake.app/Contents/share/cmake-3.6/Modules/FindBoost.cmake:743 (message):
  Imported targets not available for Boost version 106300
Call Stack (most recent call first):
  /Applications/CMake.app/Contents/share/cmake-3.6/Modules/FindBoost.cmake:842 (_Boost_COMPONENT_DEPENDENCIES)
/Applications/CMake.app/Contents/share/cmake-3.6/Modules/FindBoost.cmake:1395 (_Boost_MISSING_DEPENDENCIES)
CMakeLists.txt:6 (find_package)

Boost version: 1.63.0
Found the following Boost libraries:
  thread
CMake Warning at /Applications/CMake.app/Contents/share/cmake-3.6/Modules/FindBoost.cmake:743 (message):
  Imported targets not available for Boost version 106300
Call Stack (most recent call first):
  /Applications/CMake.app/Contents/share/cmake-3.6/Modules/FindBoost.cmake:842 (_Boost_COMPONENT_DEPENDENCIES)
  /Applications/CMake.app/Contents/share/cmake-3.6/Modules/FindBoost.cmake:1395 (_Boost_MISSING_DEPENDENCIES)
  CMakeLists.txt:7 (find_package)

推荐答案

您的 CMake 版本太旧.更新 CMake,它将起作用.

Your CMake version is too old. Update CMake and it will work.

CMake 无法检测不同 Boost 库之间的依赖关系.它们已在 FindBoost 中明确实现.
对于每个 Boost 版本,此信息由 CMake 维护人员添加,并成为下一个 CMake 版本的一部分.因此,您必须确保您的 CMake 版本是在您尝试找到的 Boost 版本之后发布的.

CMake cannot detect the dependencies between the different Boost libraries. They have explicitly implemented in FindBoost.
For every Boost release this information is added by the CMake maintainers and it gets part of the next CMake release. So you have to make sure, that your CMake version was released after the Boost version you try to find.

Boost 1.63 需要 CMake 3.7 或更新版本.
Boost 1.64 需要 CMake 3.8 或更新版本.
Boost 1.65 和 1.65.1 需要 CMake 3.9.3 或更新版本.
Boost 1.66 需要 CMake 3.11 或更新版本.
Boost 1.67 需要 CMake 3.12 或更新版本.
Boost 1.68、1.69 需要 CMake 3.13 或更新版本.
Boost 1.70 需要 CMake 3.14 或更新版本.
Boost 1.71 需要 CMake 3.15.3 或更新版本.
Boost 1.72 需要 CMake 3.16.2 或更新版本.
Boost 1.73 需要 CMake 3.17.2 或更新版本.
Boost 1.74 需要 CMake 3.19 或更新版本.
Boost 1.75 需要 CMake 3.19.5 或更新版本.
Boost 1.76 需要 CMake 3.20.3 或更新版本.
Boost 1.77 需要 CMake 3.21.3 或更新版本.

Boost 1.63 requires CMake 3.7 or newer.
Boost 1.64 requires CMake 3.8 or newer.
Boost 1.65 and 1.65.1 require CMake 3.9.3 or newer.
Boost 1.66 requires CMake 3.11 or newer.
Boost 1.67 requires CMake 3.12 or newer.
Boost 1.68, 1.69 require CMake 3.13 or newer.
Boost 1.70 requires CMake 3.14 or newer.
Boost 1.71 requires CMake 3.15.3 or newer.
Boost 1.72 requires CMake 3.16.2 or newer.
Boost 1.73 requires CMake 3.17.2 or newer.
Boost 1.74 requires CMake 3.19 or newer.
Boost 1.75 requires CMake 3.19.5 or newer.
Boost 1.76 requires CMake 3.20.3 or newer.
Boost 1.77 requires CMake 3.21.3 or newer.

从 1.77 版开始,Boost 提供了一个 BoostConfig.cmake,它废弃了 FindBoost 和所需的更改.使用

Starting with version 1.77, Boost provides a BoostConfig.cmake that obsoletes FindBoost and the required changes. Using

find_package(Boost CONFIG)

确实排除 FindBoost 文件并仅搜索配置文件.
为了兼容性,CMake 将继续提供 FindBoost.

does exclude the FindBoost file and searches only for the config file.
For compatibility CMake will remain providing FindBoost.

这篇关于CMake 找到 Boost 但导入的目标不适用于 Boost 版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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