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

查看:495
本文介绍了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版本的一部分.因此,您必须确保在尝试找到的Boost版本之后发布了您的CMake版本.

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

从版本1.70开始,Boost提供了一个BoostConfig.cmake,它使FindBoost和必需的更改过时.使用

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

find_package(Boost CONFIG)

不排除FindBoost文件,仅搜索配置文件. 虽然有一些方法可以将FindBoost从CMake中删除,但因为它将破坏对版本的支持在1.70之前的版本中,CMake正在等待执行此步骤.尽管如此,这还是在将来的CMake发行版中摆脱该版本混乱的方法.

does exclude the FindBoost file and searches only for the config file. There are thoughs to drop FindBoost from CMake, but as it would break support for versions prior 1.70, CMake is waiting to do this step. Still, this is the way to get rid of this version mess in future CMake releases.

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

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