[PATCH] D97513: Add <Project>ConfigVersion.cmake files

Alex Reinking via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Feb 25 16:31:07 PST 2021


alexreinking created this revision.
alexreinking added reviewers: chandlerc, gottesmm, pmccormick.
Herald added subscribers: cota, teijeong, rdzhabarov, tatianashp, msifontes, jurahul, Kayjukh, grosul1, Joonsoo, liufengdb, aartbik, lucyrfox, mgester, arpith-jacob, antiagainst, shauheen, rriddle, mehdi_amini, mgorny.
Herald added a reviewer: bollu.
Herald added a reviewer: sscalpone.
alexreinking requested review of this revision.
Herald added subscribers: cfe-commits, stephenneuendorffer, nicolasvasilache.
Herald added projects: clang, MLIR.

When supplying a package with `<Project>Config.cmake` files, it is required to also supply a `<Project>ConfigVersion.cmake` file which defines compatibility with version numbers. If these files aren't distributed then supplying a version number will fail. But on the other hand, //not// supplying a version number can result in the wrong package being selected. For example, because the base LLVM package //does// supply `LLVMConfigVersion.cmake`, the following can occur:

  find_package(LLVM 11.0 REQUIRED)  # Succeeds
  find_package(LLD 11.0)  # Fails because there's no version config
  find_package(LLD)  # Succeeds, finds version 10.

This patch would not affect any existing uses of the CMake build/packages because the `ConfigVersion.cmake` file is ignored when no version is given and the status quo is that supplying a version fails.

This patch also fixes a bug I opened a year ago here: https://bugs.llvm.org/show_bug.cgi?id=45027


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D97513

Files:
  clang/cmake/modules/CMakeLists.txt
  clang/cmake/modules/ClangConfigVersion.cmake.in
  flang/cmake/modules/CMakeLists.txt
  flang/cmake/modules/FlangConfigVersion.cmake.in
  lld/CMakeLists.txt
  lld/cmake/modules/CMakeLists.txt
  lld/cmake/modules/LLDConfigVersion.cmake.in
  mlir/CMakeLists.txt
  mlir/cmake/modules/CMakeLists.txt
  mlir/cmake/modules/MLIRConfigVersion.cmake.in
  polly/CMakeLists.txt
  polly/cmake/CMakeLists.txt
  polly/cmake/PollyConfigVersion.cmake.in

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D97513.326547.patch
Type: text/x-patch
Size: 12623 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210226/7678af4e/attachment-0001.bin>


More information about the cfe-commits mailing list