cmake - 如何仅在cmake中匹配主要版本

标签 cmake llvm

我正在尝试构建一个需要 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
    /usr/lib/llvm/11/lib/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中匹配主要版本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66305592/

相关文章:

linux - 我想通过使用 cmake 的正确程序检测 clang 来使用 clang/clang++ 进行编译

c++ - Clion 体系结构 x86_64 的 undefined symbol

c++ - 如何将 PHI 节点添加到每个基本 block 的开头

c++ - 使用 Clang AST 打印函数的参数

c++ - 如何将多个操作数添加到 MDNode 或 LLVM 中的元数据?

llvm - 结合使用LLVM opt和内置 channel

cmake - 如何清除/删除缓存变量

cmake - 使用 CMake 调用外部程序

linux - CMake 自动生成的文件丢失包括 CMAKE_C_INCLUDE_PATH 和 CMAKE_CXX_INCLUDE_PATH

c++ - 使用 CMake 交叉编译 : linker errors