[llvm] fac791d - Export `LLVM_VERSION_MAJOR` CMake variable as a directory property (#83346)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Mar 5 06:59:32 PST 2024
Author: Benoit Jacob
Date: 2024-03-05T09:59:28-05:00
New Revision: fac791d4e1d879c19bfbbbfa89dc4186f56af34c
URL: https://github.com/llvm/llvm-project/commit/fac791d4e1d879c19bfbbbfa89dc4186f56af34c
DIFF: https://github.com/llvm/llvm-project/commit/fac791d4e1d879c19bfbbbfa89dc4186f56af34c.diff
LOG: Export `LLVM_VERSION_MAJOR` CMake variable as a directory property (#83346)
This allows users who include `llvm-project` as a subrepository to
access the `LLVM_VERSION_MAJOR` variable on par with if they were
relying on an installed LLVM and `FindLLVM.cmake`. They just need to do
something like:
```
get_directory_property(LLVM_VERSION_MAJOR DIRECTORY "third_party/llvm-project/llvm" LLVM_VERSION_MAJOR)
```
Context: https://github.com/openxla/iree/pull/16606 -- like other
projects with similar needs that I found by some googling, our
work-around had been to rely on the CMake cached variable
`CLANG_EXECUTABLE_VERSION`. Being cached, it over time inevitably ended
up having a wrong value.
Added:
Modified:
llvm/CMakeLists.txt
Removed:
################################################################################
diff --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt
index 651f17879fad24..111c8cfa15d828 100644
--- a/llvm/CMakeLists.txt
+++ b/llvm/CMakeLists.txt
@@ -28,6 +28,8 @@ if(NOT DEFINED LLVM_VERSION_SUFFIX)
set(LLVM_VERSION_SUFFIX git)
endif()
+set_directory_properties(PROPERTIES LLVM_VERSION_MAJOR "${LLVM_VERSION_MAJOR}")
+
if (NOT PACKAGE_VERSION)
set(PACKAGE_VERSION
"${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}.${LLVM_VERSION_PATCH}${LLVM_VERSION_SUFFIX}")
More information about the llvm-commits
mailing list