[Lldb-commits] [clang] [lldb] [llvm] [cmake][llvm] Limit the number of Xcode schemes created by default (PR #101243)
Jon Roelofs via lldb-commits
lldb-commits at lists.llvm.org
Tue Jul 30 16:30:35 PDT 2024
https://github.com/jroelofs updated https://github.com/llvm/llvm-project/pull/101243
>From 61371af08b82e1229c34b43f56772813c2f74b1c Mon Sep 17 00:00:00 2001
From: Jon Roelofs <jonathan_roelofs at apple.com>
Date: Tue, 30 Jul 2024 13:56:21 -0700
Subject: [PATCH 1/7] [cmake][llvm] Limit the number of Xcode schemes created
by default
CMake -GXcode would otherwise offer to create one scheme for each target, which
ends up being a lot. For t push --forcenow, limit the default to the `check-*` LIT targets,
plus `ALL_BUILD` and `install`.
---
cmake/Modules/Xcode.cmake | 24 ++++++++++++++++++++++++
llvm/CMakeLists.txt | 4 ++++
llvm/cmake/modules/AddLLVM.cmake | 1 +
3 files changed, 29 insertions(+)
create mode 100644 cmake/Modules/Xcode.cmake
diff --git a/cmake/Modules/Xcode.cmake b/cmake/Modules/Xcode.cmake
new file mode 100644
index 0000000000000..466cf79eb8b00
--- /dev/null
+++ b/cmake/Modules/Xcode.cmake
@@ -0,0 +1,24 @@
+# When this is enabled, CMake will generate schemes for every target, but not
+# all of them make sense to surface in the Xcode UI by default.
+set(CMAKE_XCODE_GENERATE_SCHEME YES)
+
+# Enumerate all the targets in a directory.
+macro(get_all_targets targets dir)
+ get_property(sub_dirs DIRECTORY ${dir} PROPERTY SUBDIRECTORIES)
+ foreach(subdir ${sub_dirs})
+ get_all_targets(${targets} ${subdir})
+ endforeach()
+ get_property(local_targets DIRECTORY ${dir} PROPERTY BUILDSYSTEM_TARGETS)
+ list(APPEND ${targets} ${local_targets})
+endmacro()
+
+get_all_targets(all_targets ${PROJECT_SOURCE_DIR})
+
+# Turn off scheme generation by default for targets that do not have
+# XCODE_GENERATE_SCHEME set.
+foreach(target ${all_targets})
+ get_target_property(value ${target} XCODE_GENERATE_SCHEME)
+ if("${value}" STREQUAL "value-NOTFOUND")
+ set_target_properties(${target} PROPERTIES XCODE_GENERATE_SCHEME NO)
+ endif()
+endforeach()
diff --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt
index 12618966c4adf..501b9ea288053 100644
--- a/llvm/CMakeLists.txt
+++ b/llvm/CMakeLists.txt
@@ -1423,3 +1423,7 @@ endif()
if (LLVM_INCLUDE_UTILS AND LLVM_INCLUDE_TOOLS)
add_subdirectory(utils/llvm-locstats)
endif()
+
+if (XCODE)
+ include(Xcode)
+endif()
diff --git a/llvm/cmake/modules/AddLLVM.cmake b/llvm/cmake/modules/AddLLVM.cmake
index 03f4e1f190fd9..f4f71b35ffa70 100644
--- a/llvm/cmake/modules/AddLLVM.cmake
+++ b/llvm/cmake/modules/AddLLVM.cmake
@@ -2043,6 +2043,7 @@ function(add_lit_target target comment)
# Tests should be excluded from "Build Solution".
set_target_properties(${target} PROPERTIES EXCLUDE_FROM_DEFAULT_BUILD ON)
+ set_target_properties(${target} PROPERTIES XCODE_GENERATE_SCHEME ON)
endfunction()
# Convert a target name like check-clang to a variable name like CLANG.
>From 9b294dcb88c5aeb377454338773fabbaf58e41d6 Mon Sep 17 00:00:00 2001
From: Jon Roelofs <jonathan_roelofs at apple.com>
Date: Tue, 30 Jul 2024 14:36:56 -0700
Subject: [PATCH 2/7] take Jonas' suggestion
---
cmake/Modules/Xcode.cmake | 24 ------------------------
llvm/CMakeLists.txt | 4 ----
2 files changed, 28 deletions(-)
delete mode 100644 cmake/Modules/Xcode.cmake
diff --git a/cmake/Modules/Xcode.cmake b/cmake/Modules/Xcode.cmake
deleted file mode 100644
index 466cf79eb8b00..0000000000000
--- a/cmake/Modules/Xcode.cmake
+++ /dev/null
@@ -1,24 +0,0 @@
-# When this is enabled, CMake will generate schemes for every target, but not
-# all of them make sense to surface in the Xcode UI by default.
-set(CMAKE_XCODE_GENERATE_SCHEME YES)
-
-# Enumerate all the targets in a directory.
-macro(get_all_targets targets dir)
- get_property(sub_dirs DIRECTORY ${dir} PROPERTY SUBDIRECTORIES)
- foreach(subdir ${sub_dirs})
- get_all_targets(${targets} ${subdir})
- endforeach()
- get_property(local_targets DIRECTORY ${dir} PROPERTY BUILDSYSTEM_TARGETS)
- list(APPEND ${targets} ${local_targets})
-endmacro()
-
-get_all_targets(all_targets ${PROJECT_SOURCE_DIR})
-
-# Turn off scheme generation by default for targets that do not have
-# XCODE_GENERATE_SCHEME set.
-foreach(target ${all_targets})
- get_target_property(value ${target} XCODE_GENERATE_SCHEME)
- if("${value}" STREQUAL "value-NOTFOUND")
- set_target_properties(${target} PROPERTIES XCODE_GENERATE_SCHEME NO)
- endif()
-endforeach()
diff --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt
index 501b9ea288053..12618966c4adf 100644
--- a/llvm/CMakeLists.txt
+++ b/llvm/CMakeLists.txt
@@ -1423,7 +1423,3 @@ endif()
if (LLVM_INCLUDE_UTILS AND LLVM_INCLUDE_TOOLS)
add_subdirectory(utils/llvm-locstats)
endif()
-
-if (XCODE)
- include(Xcode)
-endif()
>From 834f4b1d7d7a062d6de08a3c285890c580097406 Mon Sep 17 00:00:00 2001
From: Jon Roelofs <jonathan_roelofs at apple.com>
Date: Tue, 30 Jul 2024 14:44:27 -0700
Subject: [PATCH 3/7] generate schemes for llvm_add_tool tools, too
---
llvm/cmake/modules/AddLLVM.cmake | 1 +
1 file changed, 1 insertion(+)
diff --git a/llvm/cmake/modules/AddLLVM.cmake b/llvm/cmake/modules/AddLLVM.cmake
index f4f71b35ffa70..ac47e884ac229 100644
--- a/llvm/cmake/modules/AddLLVM.cmake
+++ b/llvm/cmake/modules/AddLLVM.cmake
@@ -1452,6 +1452,7 @@ macro(llvm_add_tool project name)
endif()
get_subproject_title(subproject_title)
set_target_properties(${name} PROPERTIES FOLDER "${subproject_title}/Tools")
+ set_target_properties(${name} PROPERTIES XCODE_GENERATE_SCHEME ON)
endmacro(llvm_add_tool project name)
macro(add_llvm_tool name)
>From a7f082152a34269f017c145722603ec4a009cece Mon Sep 17 00:00:00 2001
From: Jon Roelofs <jonathan_roelofs at apple.com>
Date: Tue, 30 Jul 2024 14:50:55 -0700
Subject: [PATCH 4/7] and clang tools, too
---
clang/cmake/modules/AddClang.cmake | 2 ++
1 file changed, 2 insertions(+)
diff --git a/clang/cmake/modules/AddClang.cmake b/clang/cmake/modules/AddClang.cmake
index 9d09be1936847..5327b5d2f0892 100644
--- a/clang/cmake/modules/AddClang.cmake
+++ b/clang/cmake/modules/AddClang.cmake
@@ -147,6 +147,7 @@ endmacro(add_clang_library)
macro(add_clang_executable name)
add_llvm_executable( ${name} ${ARGN} )
set_clang_windows_version_resource_properties(${name})
+ set_target_properties(${name} PROPERTIES XCODE_GENERATE_SCHEME ON)
endmacro(add_clang_executable)
macro(add_clang_tool name)
@@ -181,6 +182,7 @@ macro(add_clang_tool name)
set_property(GLOBAL APPEND PROPERTY CLANG_EXPORTS ${name})
endif()
endif()
+ set_target_properties(${name} PROPERTIES XCODE_GENERATE_SCHEME ON)
endmacro()
macro(add_clang_symlink name dest)
>From 8923c8905f40e8031c73b57e9dff32ec80a99899 Mon Sep 17 00:00:00 2001
From: Jon Roelofs <jonathan_roelofs at apple.com>
Date: Tue, 30 Jul 2024 15:24:09 -0700
Subject: [PATCH 5/7] and lldb
---
lldb/cmake/modules/AddLLDB.cmake | 1 +
1 file changed, 1 insertion(+)
diff --git a/lldb/cmake/modules/AddLLDB.cmake b/lldb/cmake/modules/AddLLDB.cmake
index 538029037dd46..0a81ec5092185 100644
--- a/lldb/cmake/modules/AddLLDB.cmake
+++ b/lldb/cmake/modules/AddLLDB.cmake
@@ -258,6 +258,7 @@ function(add_lldb_tool name)
endif()
add_lldb_executable(${name} GENERATE_INSTALL ${ARG_UNPARSED_ARGUMENTS})
+ set_target_properties(${name} PROPERTIES XCODE_GENERATE_SCHEME ON)
endfunction()
# The test suite relies on finding LLDB.framework binary resources in the
>From bc8b71df3fe9b1be297142a47a65ddd78718ef81 Mon Sep 17 00:00:00 2001
From: Jon Roelofs <jonathan_roelofs at apple.com>
Date: Tue, 30 Jul 2024 16:02:38 -0700
Subject: [PATCH 6/7] add -DLLVM_XCODE_EXTRA_TARGET_SCHEMES="TargetParserTests"
flag
---
llvm/CMakeLists.txt | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt
index 12618966c4adf..54ac89d732aad 100644
--- a/llvm/CMakeLists.txt
+++ b/llvm/CMakeLists.txt
@@ -1423,3 +1423,11 @@ endif()
if (LLVM_INCLUDE_UTILS AND LLVM_INCLUDE_TOOLS)
add_subdirectory(utils/llvm-locstats)
endif()
+
+if (XCODE)
+ set(LLVM_XCODE_EXTRA_TARGET_SCHEMES "" CACHE STRING "Specifies an extra list of targets to turn into schemes")
+
+ foreach(target ${LLVM_XCODE_EXTRA_TARGET_SCHEMES})
+ set_target_properties(${target} PROPERTIES XCODE_GENERATE_SCHEME ON)
+ endforeach()
+endif()
>From a189270a2be8690ca060ee7d9888a0d8a76f97c5 Mon Sep 17 00:00:00 2001
From: Jon Roelofs <jonathan_roelofs at apple.com>
Date: Tue, 30 Jul 2024 16:30:18 -0700
Subject: [PATCH 7/7] add a comment explaining the config variable
---
llvm/CMakeLists.txt | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt
index 54ac89d732aad..699de1ccd870c 100644
--- a/llvm/CMakeLists.txt
+++ b/llvm/CMakeLists.txt
@@ -1425,6 +1425,11 @@ if (LLVM_INCLUDE_UTILS AND LLVM_INCLUDE_TOOLS)
endif()
if (XCODE)
+ # For additional targets that you would like to add schemes, specify e.g:
+ #
+ # -DLLVM_XCODE_EXTRA_TARGET_SCHEMES="TargetParserTests;SupportTests"
+ #
+ # at CMake configure time.
set(LLVM_XCODE_EXTRA_TARGET_SCHEMES "" CACHE STRING "Specifies an extra list of targets to turn into schemes")
foreach(target ${LLVM_XCODE_EXTRA_TARGET_SCHEMES})
More information about the lldb-commits
mailing list