This is an archive of the discontinued LLVM Phabricator instance.

Add version to all LLVM cmake package
ClosedPublic

Authored by thopre on Nov 18 2022, 2:38 AM.

Details

Summary

Add a version to non-LLVM cmake package so that users needing an exact
version match can use the version parameter to find_package. Also adjust
the find_package(LLVM) to use an exact version match as well.

Diff Detail

Event Timeline

thopre created this revision.Nov 18 2022, 2:38 AM
Herald added projects: Restricted Project, Restricted Project. · View Herald Transcript
thopre requested review of this revision.Nov 18 2022, 2:38 AM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptNov 18 2022, 2:38 AM
arsenm accepted this revision.Nov 18 2022, 2:00 PM

I thought we had this already. The amount of boiler plate required repeated in each component is depressing, but I wouldn't be surprised if it's really needed

This revision is now accepted and ready to land.Nov 18 2022, 2:00 PM

I thought we had this already. The amount of boiler plate required repeated in each component is depressing, but I wouldn't be surprised if it's really needed

I could configure the LLVMVersion file in llvm/cmake/module directly but I would need to refer to it from all those modified CMakeLists.txt and it didn't feel very clean either.

stellaraccident accepted this revision.Nov 19 2022, 4:32 PM

As mentioned, the duplication is annoying but I suspect is the least bad way to do it.

This revision was automatically updated to reflect the committed changes.
mceier added a subscriber: mceier.Nov 24 2022, 12:59 PM
mceier added inline comments.
clang/cmake/modules/ClangConfig.cmake.in
6

I think instead of @LLVM_VERSION@ it should be ${LLVM_VERSION} since @LLVM_VERSION@ can be something like 16.0.0gitfce7a7aa when LLVM_VERSION_SUFFIX is set and that value is incorrect according to cmake find_package:

find_package called with invalid argument "16.0.0gitfce7a7aa"

This error message is produced by cmake when configuring standalone build of lldb:

CMake Error at /usr/lib/llvm/16/lib64/cmake/clang/ClangConfig.cmake:10 (find_package):

find_package called with invalid argument "16.0.0gitfce7a7aa"

Call Stack (most recent call first):

cmake/modules/LLDBStandalone.cmake:10 (find_package)
CMakeLists.txt:30 (include)
thopre reopened this revision.Nov 25 2022, 4:30 AM
thopre added inline comments.
clang/cmake/modules/ClangConfig.cmake.in
6

Doh, yeah it was meant to use the variable above. I used PACKAGE_VERSION initially which is why I had those @@. Weird that it worked on my test despite using a git build. I've reverted and will upload a new version here.

This revision is now accepted and ready to land.Nov 25 2022, 4:30 AM
thopre updated this revision to Diff 477916.Nov 25 2022, 4:30 AM

Use LLVM_VERSION as a CMake variable and LLVM_VERSION_* as substitutions

thopre requested review of this revision.Nov 25 2022, 4:31 AM
mceier accepted this revision.Nov 25 2022, 7:06 AM
This revision is now accepted and ready to land.Nov 25 2022, 7:06 AM
This revision was landed with ongoing or failed builds.Nov 25 2022, 1:58 PM
This revision was automatically updated to reflect the committed changes.