[llvm] [llvm][CMake] Introduce LLVM_RUNTIME_<project>_BUILD in CMake (PR #88934)
Michael Klemm via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 17 05:27:58 PDT 2024
https://github.com/mjklemm updated https://github.com/llvm/llvm-project/pull/88934
>From 4f53ec79994aa25db12ad4bc7f1becbc32f6e047 Mon Sep 17 00:00:00 2001
From: Michael Klemm <michael.klemm at amd.com>
Date: Tue, 16 Apr 2024 11:45:59 -0500
Subject: [PATCH 1/2] Add CMake code to set LLVM_RUNTIME_xxxx_ENABLED
---
llvm/CMakeLists.txt | 29 +++++++++++++++++++++++++++++
1 file changed, 29 insertions(+)
diff --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt
index d511376e18ba5e..e33514c4cd0d7f 100644
--- a/llvm/CMakeLists.txt
+++ b/llvm/CMakeLists.txt
@@ -253,6 +253,35 @@ if (LLVM_ENABLE_PROJECTS_USED OR NOT LLVM_ENABLE_PROJECTS STREQUAL "")
endif()
unset(SHOULD_ENABLE_PROJECT)
+# Set LLVM_RUNTIME_<project>_BUILD variables if a sub-project is enabled to be built as
+# a runtime.
+foreach(proj ${LLVM_SUPPORTED_RUNTIMES})
+ set(SHOULD_ENABLE_PROJECT FALSE)
+ string(TOUPPER "${proj}" upper_proj)
+ string(REGEX REPLACE "-" "_" upper_proj ${upper_proj})
+ if ("${proj}" IN_LIST LLVM_ENABLE_RUNTIMES)
+ message(STATUS "${proj} runtime is enabled")
+ set(SHOULD_ENABLE_PROJECT TRUE)
+ set(PROJ_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../${proj}")
+ if(NOT EXISTS "${PROJ_DIR}" OR NOT IS_DIRECTORY "${PROJ_DIR}")
+ message(FATAL_ERROR "LLVM_ENABLE_RUNTIMES requests ${proj} but directory not found: ${PROJ_DIR}")
+ endif()
+ if(LLVM_EXTERNAL_${upper_proj}_SOURCE_DIR STREQUAL "" )
+ set(LLVM_EXTERNAL_${upper_proj}_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../${proj}" CACHE PATH "" FORCE)
+ else()
+ set(LLVM_EXTERNAL_${upper_proj}_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../${proj}" CACHE PATH "")
+ endif()
+ else()
+ message(STATUS "${proj} runtime is disabled")
+ set(SHOULD_ENABLE_PROJECT FALSE)
+ endif()
+ set(LLVM_RUNTIME_${upper_proj}_BUILD
+ ${SHOULD_ENABLE_PROJECT}
+ CACHE
+ BOOL "Whether to build runtime ${upper_proj} as part of LLVM" FORCE)
+endforeach()
+unset(SHOULD_ENABLE_PROJECT)
+
# Build llvm with ccache if the package is present
set(LLVM_CCACHE_BUILD OFF CACHE BOOL "Set to ON for a ccache enabled build")
if(LLVM_CCACHE_BUILD)
>From c61dfb7bfd2778dba27f4446ba7994a48406af4b Mon Sep 17 00:00:00 2001
From: Michael Klemm <michael.klemm at amd.com>
Date: Wed, 17 Apr 2024 07:27:37 -0500
Subject: [PATCH 2/2] Be a bit clearer that LLVM_RUNTIME_<project>_BUILD should
be directly used
---
llvm/CMakeLists.txt | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt
index e33514c4cd0d7f..0876bbf11bd516 100644
--- a/llvm/CMakeLists.txt
+++ b/llvm/CMakeLists.txt
@@ -254,7 +254,8 @@ endif()
unset(SHOULD_ENABLE_PROJECT)
# Set LLVM_RUNTIME_<project>_BUILD variables if a sub-project is enabled to be built as
-# a runtime.
+# a runtime. As with LLVM_TOOL_<project>_BUILD, the LLVM_RUNTIME_<project>_BUILD variables
+# should be not directly used from the CMake configuration command line.
foreach(proj ${LLVM_SUPPORTED_RUNTIMES})
set(SHOULD_ENABLE_PROJECT FALSE)
string(TOUPPER "${proj}" upper_proj)
More information about the llvm-commits
mailing list