3

I am trying to build a project that requires LLVM 11 as a dependency. They bundle a copy of LLVM 11.0.1. I want to build it against the system version, which is LLVM 11.1.0. In the cmake build files, they have:

find_package(LLVM 11.0 CONFIG)

If you try to use the system LLVM, you get the following error:

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)

I thought that changing the line to this would fix it:

find_package(LLVM 11 CONFIG)

but it doesn't, and I get the exact same error:

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)

What am I missing? Here is a full link to the code: https://github.com/RPCS3/rpcs3/blob/master/3rdparty/llvm.cmake

matoro
  • 181
  • 1
  • 13

1 Answers1

2

Whether a version is deemed compatible to the requested version is specified by the package you're trying to find. I haven't looked at the LLVM config, but I suspect it specifies that only the exact version is compatible instead of all versions with the same major version.

If you're running CMake 3.19 or later you can pass a version range to find_package, so you could try find_package(LLVM 11...<12 CONFIG) instead.

Corristo
  • 4,911
  • 1
  • 20
  • 36
  • 1
    That change did not work, but it did point me towards what the issue was. In `LLVMConfigVersion.cmake` there is this comment: `LLVM is API-compatible only with matching major.minor versions and patch versions not less than that requested.` It then limits matches to requests for versions starting with 11.1. So I guess it does not make sense to request 11.x if 11.0.x and 11.1.x are API-incompatible. Thanks! – matoro Feb 21 '21 at 22:33