程序问答   发布时间:2022-06-01  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了如何仅在 cmake 中匹配主要版本大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

如何解决如何仅在 cmake 中匹配主要版本?

开发过程中遇到如何仅在 cmake 中匹配主要版本的问题如何解决?下面主要结合日常开发的经验,给出你关于如何仅在 cmake 中匹配主要版本的解决方法建议,希望对你解决如何仅在 cmake 中匹配主要版本有所启发或帮助;

我正在尝试构建一个需要 LLVM 11 作为依赖项的项目。他们捆绑了 LLVM 11.0.1 的副本。我想针对系统版本构建它,即 LLVM 11.1.0。在 cmake 构建文件中,它们有:

find_package(LLVM 11.0 CONfig)

如果您尝试使用系统 LLVM,则会出现以下错误:

CMake Warning at 3rdparty/llvm.cmake:42 (find_package):
  Could not find a configuration file for package "LLVM" that is compatible
  with requested version "11.0".

  The following configuration files were consIDered but not accepted:

    /usr/lib/llvm/11/lib64/cmake/llvm/LLVMConfig.cmake,version: 11.1.0
    /usr/lib/llvm/11/lib/cmake/llvm/LLVMConfig.cmake,version: 11.1.0

Call Stack (most recent call first):
  3rdparty/CMakeLists.txt:436 (include)

我认为将行更改为此可以解决它:

find_package(LLVM 11 CONfig)

但它没有,我得到完全相同的错误:

CMake Warning at 3rdparty/llvm.cmake:42 (find_package):
  Could not find a configuration file for package "LLVM" that is compatible
  with requested version "11".

  The following configuration files were consIDered but not accepted:

    /usr/lib/llvm/11/lib64/cmake/llvm/LLVMConfig.cmake,version: 11.1.0

Call Stack (most recent call first):
  3rdparty/CMakeLists.txt:436 (include)

我错过了什么?这是代码的完整链接:https://github.com/RPCS3/rpcs3/blob/master/3rdparty/llvm.cmake

解决方法

某个版本是否与请求的版本兼容由您尝试查找的软件包指定。我没有看过 LLVM 配置,但我怀疑它指定只有确切版本兼容,而不是所有版本都具有相同的主要版本。

如果您运行的是 CMake 3.19 或更高版本,您可以将版本范围传递给 find_package,因此您可以尝试使用 find_package(LLVM 11...<12 CONFIG)

大佬总结

以上是大佬教程为你收集整理的如何仅在 cmake 中匹配主要版本全部内容,希望文章能够帮你解决如何仅在 cmake 中匹配主要版本所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。
标签: