Skip to content

Commit fac791d

Browse files
authored
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: iree-org/iree#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.
1 parent a64975f commit fac791d

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

llvm/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ if(NOT DEFINED LLVM_VERSION_SUFFIX)
2828
set(LLVM_VERSION_SUFFIX git)
2929
endif()
3030

31+
set_directory_properties(PROPERTIES LLVM_VERSION_MAJOR "${LLVM_VERSION_MAJOR}")
32+
3133
if (NOT PACKAGE_VERSION)
3234
set(PACKAGE_VERSION
3335
"${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}.${LLVM_VERSION_PATCH}${LLVM_VERSION_SUFFIX}")

0 commit comments

Comments
 (0)