How to match major version only in cmake

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



Read more here: https://stackoverflow.com/questions/66305592/how-to-match-major-version-only-in-cmake

Content Attribution

This content was originally published by matoro at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: