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
/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)
。
推荐阅读
- ios - 以特定格式获取当前日期
- python - 解析python字典时出现键错误
- javascript - 即使在大写和小写之间混合使用,也可以识别单词
- .net - CfSetInSyncState() Win32 函数的 .NET 模拟?
- c# - SmtpClient 异常未进入 SmtpFailedRecipientsException
- react-native - 如何在反应式原生样式中更改单一样式
- c# - Xamarin.Forms 本地化资源中的“不间断空间”
- php - php laravel 从排序规则 \App\CourseStart->find(any)->students->count() 调用函数并连接
- python - 我的 Django 登录/注册表单保存了除金额之外的所有内容
- java - 如何在 Spring Boot 中使用 JPA 从数据库中获取特定列(尝试从数据库中获取特定列时出现异常)?