[llvm] [cmake] Pass -resource-dir to external projects as CMAKE_<LANG>_FLAGS_INIT instead of as a force override (PR #87330)

Raul Tambre via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 8 03:15:18 PDT 2024


https://github.com/tambry updated https://github.com/llvm/llvm-project/pull/87330

>From 1a32a7b874486d478e9e0adaf5e34e733cb9a8eb Mon Sep 17 00:00:00 2001
From: Raul Tambre <raul at tambre.ee>
Date: Mon, 8 Apr 2024 13:15:04 +0300
Subject: [PATCH] [cmake] Pass -resource-dir to external projects as
 CMAKE_<LANG>_FLAGS_INIT instead of as a force override

It's useful to use toolchain files for configuring runtimes builds.
Setting CMAKE_<LANG>_FLAGS is however forceful and precludes initialization from the _INIT variant meant to be set by toolchains.
The toolchain file still needs to append instead of just setting and be idempotent (`include_guard()`), but this way at least a special toolchain to account for LLVM's won't be required.
---
 llvm/cmake/modules/LLVMExternalProjectUtils.cmake | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/llvm/cmake/modules/LLVMExternalProjectUtils.cmake b/llvm/cmake/modules/LLVMExternalProjectUtils.cmake
index 2672f90f579bd9..114bfa38df4304 100644
--- a/llvm/cmake/modules/LLVMExternalProjectUtils.cmake
+++ b/llvm/cmake/modules/LLVMExternalProjectUtils.cmake
@@ -287,7 +287,7 @@ function(llvm_ExternalProject_Add name source_dir)
       endif()
       set(flag_types ASM C CXX MODULE_LINKER SHARED_LINKER EXE_LINKER)
       foreach(type ${flag_types})
-        set(${type}_flag -DCMAKE_${type}_FLAGS=-resource-dir=${resource_dir})
+        set(${type}_flag -DCMAKE_${type}_FLAGS_INIT=-resource-dir=${resource_dir})
       endforeach()
       string(REPLACE ";" "|" flag_string "${flag_types}")
       foreach(arg ${ARG_CMAKE_ARGS})



More information about the llvm-commits mailing list