[llvm] Export `LLVM_VERSION_*` CMake variables to `PARENT_SCOPE` (PR #83346)

Benoit Jacob via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 1 07:54:29 PST 2024


https://github.com/bjacob updated https://github.com/llvm/llvm-project/pull/83346

>From 6848a193c5dcdd0825ae65a0c13b51c1930db29f Mon Sep 17 00:00:00 2001
From: Benoit Jacob <jacob.benoit.1 at gmail.com>
Date: Wed, 28 Feb 2024 17:00:28 -0500
Subject: [PATCH] llvm-version-major

---
 llvm/CMakeLists.txt | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt
index 651f17879fad24..88f28d9074a075 100644
--- a/llvm/CMakeLists.txt
+++ b/llvm/CMakeLists.txt
@@ -28,6 +28,15 @@ if(NOT DEFINED LLVM_VERSION_SUFFIX)
   set(LLVM_VERSION_SUFFIX git)
 endif()
 
+# Export a few LLVM version identifiers for users who use LLVM as a subdir.
+get_directory_property(_LLVM_HAS_PARENT_DIRECTORY PARENT_DIRECTORY)
+if (_LLVM_HAS_PARENT_DIRECTORY)
+  set(LLVM_VERSION_MAJOR "${LLVM_VERSION_MAJOR}" PARENT_SCOPE)
+  set(LLVM_VERSION_MINOR "${LLVM_VERSION_MINOR}" PARENT_SCOPE)
+  set(LLVM_VERSION_PATCH "${LLVM_VERSION_PATCH}" PARENT_SCOPE)
+  set(LLVM_VERSION_SUFFIX "${LLVM_VERSION_SUFFIX}" PARENT_SCOPE)
+endif()
+
 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