File 0003-cmake-Allow-any-LLVM-release-for-debug-builds.patch of Package bpftrace

From 4e96768dd8f710ae727caa38397f3edb73faf156 Mon Sep 17 00:00:00 2001
From: Daniel Xu <dxu@dxuuu.xyz>
Date: Thu, 19 Sep 2024 11:17:25 +0200
Subject: [PATCH 2/3] cmake: Allow any LLVM release for debug builds

---
 CMakeLists.txt | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 05ca8dcc..025ff321 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -149,7 +149,15 @@ else()
 endif()
 
 set(MIN_LLVM_MAJOR 13)
-set(MAX_LLVM_MAJOR 18)
+if(CMAKE_BUILD_TYPE STREQUAL "Debug")
+  # We assume bpftrace is not being packaged when CMAKE_BUILD_TYPE=Debug.
+  # So allow building with any LLVM version. This is purely for developers.
+  # Packagers are highly discouraged from shipping bpftrace with untested LLVM
+  # releases.
+  set(MAX_LLVM_MAJOR 999)
+else()
+  set(MAX_LLVM_MAJOR 18)
+endif()
 
 if((${LLVM_VERSION_MAJOR} VERSION_LESS ${MIN_LLVM_MAJOR}) OR (${LLVM_VERSION_MAJOR} VERSION_GREATER ${MAX_LLVM_MAJOR}))
   message(SEND_ERROR "Unsupported LLVM version found via ${LLVM_INCLUDE_DIRS}: ${LLVM_VERSION_MAJOR}")
-- 
2.47.1

openSUSE Build Service is sponsored by