[llvm] 52d7c0b - [cmake] Don't include symlinks to tools in Build-all when `LLVM_BUILD_TOOLS` is off
Markus Böck via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 30 05:46:52 PDT 2022
Author: Markus Böck
Date: 2022-08-30T14:46:22+02:00
New Revision: 52d7c0b760a1443933a7196bb250e7ef5b6ea50d
URL: https://github.com/llvm/llvm-project/commit/52d7c0b760a1443933a7196bb250e7ef5b6ea50d
DIFF: https://github.com/llvm/llvm-project/commit/52d7c0b760a1443933a7196bb250e7ef5b6ea50d.diff
LOG: [cmake] Don't include symlinks to tools in Build-all when `LLVM_BUILD_TOOLS` is off
When building LLVM with LLVM_BUILD_TOOLS as OFF, numerous tools such as llvm-ar or llvm-objcopy end up still being built. The reason for this is that the symlink targets are unconditionally included in a Build-all build, causing the tool they're symlinking to be built after all.
This patch changes that behaviour to be more intuitive by only including the symlink in a Build-all build if the target they're linking to is also included.
Differential Revision: https://reviews.llvm.org/D132883
Added:
Modified:
llvm/cmake/modules/AddLLVM.cmake
Removed:
################################################################################
diff --git a/llvm/cmake/modules/AddLLVM.cmake b/llvm/cmake/modules/AddLLVM.cmake
index 057431208322e..cd1e499cde072 100644
--- a/llvm/cmake/modules/AddLLVM.cmake
+++ b/llvm/cmake/modules/AddLLVM.cmake
@@ -2135,7 +2135,14 @@ function(llvm_add_tool_symlink project link_name target)
add_custom_command(OUTPUT ${output_path}
COMMAND ${CMAKE_COMMAND} -E ${LLVM_LINK_OR_COPY} "${dest_binary}" "${output_path}"
DEPENDS ${target})
- add_custom_target(${target_name} ALL DEPENDS ${target} ${output_path})
+
+ # TODO: Make use of generator expressions below once CMake 3.19 or higher is the minimum supported version.
+ set(should_build_all)
+ get_target_property(target_excluded_from_all ${target} EXCLUDE_FROM_ALL)
+ if (NOT target_excluded_from_all)
+ set(should_build_all ALL)
+ endif()
+ add_custom_target(${target_name} ${should_build_all} DEPENDS ${target} ${output_path})
set_target_properties(${target_name} PROPERTIES FOLDER Tools)
# Make sure both the link and target are toolchain tools
More information about the llvm-commits
mailing list