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

Alex Reinking via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Feb 26 12:17:50 PST 2021


alexreinking added a comment.

So with this patch, I tried to imitate the existing code as much as possible. However, I think it would be quite a bit better to use the `write_basic_package_version_file` command from `CMakePackageConfigHelpers`. It gained support for major + minor version compatibility matching in CMake 3.11. Since LLVM is on 3.13 now, I don't see a reason not to use this. Instead of the existing `configure_file` and `*ConfigVersion.cmake.in` combo, we would delete the template (`.in`) and just write:

  include(CMakePackageConfigHelpers)
  write_basic_package_version_file(
      ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/PollyConfigVersion.cmake
      VERSION ${POLLY_VERSION}
      COMPATIBILITY SameMinorVersion
  )

If the subproject had proper calls to `project()`, like `project(Polly VERSION ${POLLY_VERSION})`, then `write_basic_package_version_file` would default its `VERSION` argument to `${PROJECT_VERSION}`.

The template `ConfigVersion.cmake.in` files are also missing an architecture check, so it's possible that a 64-bit build of LLVM could get picked up by a project calling `find_package` while cross compiling to 32-bit. The ones generated by `write_basic_package_version_file` have this check.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D97513/new/

https://reviews.llvm.org/D97513



More information about the cfe-commits mailing list