[PATCH] D136572: Harmonize cmake_policy() across standalone builds of all projects
Martin Storsjö via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Oct 27 05:10:37 PDT 2022
mstorsjo added a comment.
In D136572#3888177 <https://reviews.llvm.org/D136572#3888177>, @mstorsjo wrote:
> This broke builds where clang/lld/lldb are symlinked into `llvm/tools` instead of specified via `LLVM_ENABLE_PROJECTS` - since `${CMAKE_CURRENT_SOURCE_DIR}/../cmake` doesn't find anything in that context.
This aspect, for finding the shared cmake directory, is handled elsewhere by the main LLVM build setting the `LLVM_COMMON_CMAKE_UTILS` variable, and if not found, it's assumed to be in `${CMAKE_CURRENT_SOURCE_DIR}/..`. See e.g. https://github.com/llvm/llvm-project/blob/llvmorg-15.0.0/lld/CMakeLists.txt#L198-L206.
Since this is invoked very early in the per-project cmakefiles, I guess we can't assume to have all those variables set up yet, but e.g. something like this fixes the issue for me:
diff --git a/lld/CMakeLists.txt b/lld/CMakeLists.txt
index 964bc3fd8b17..530f52b05bac 100644
--- a/lld/CMakeLists.txt
+++ b/lld/CMakeLists.txt
@@ -1,6 +1,11 @@
cmake_minimum_required(VERSION 3.13.4)
-include(${CMAKE_CURRENT_SOURCE_DIR}/../cmake/Modules/CMakePolicy.cmake
- NO_POLICY_SCOPE)
+if(DEFINED LLVM_COMMON_CMAKE_UTILS)
+ include(${LLVM_COMMON_CMAKE_UTILS}/Modules/CMakePolicy.cmake
+ NO_POLICY_SCOPE)
+else()
+ include(${CMAKE_CURRENT_SOURCE_DIR}/../cmake/Modules/CMakePolicy.cmake
+ NO_POLICY_SCOPE)
+endif()
# If we are not building as a part of LLVM, build LLD as an
# standalone project, using LLVM as an external library:
(And the same applied for all the other subprojects.) It's admittedly not very pretty though...
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D136572/new/
https://reviews.llvm.org/D136572
More information about the cfe-commits
mailing list