https://github.com/labath created 
https://github.com/llvm/llvm-project/pull/142587

Replace (questionable) header globs with an explicit argument supported by 
llvm_add_library.

>From 450e714d9eb1a6f15a6b6065cf0c60f120948f65 Mon Sep 17 00:00:00 2001
From: Pavel Labath <pa...@labath.sk>
Date: Tue, 3 Jun 2025 13:45:04 +0200
Subject: [PATCH] [lldb/cmake] Use ADDITIONAL_HEADER(_DIR)?S

Replace (questionable) header globs with an explicit argument supported
by llvm_add_library.
---
 lldb/CMakeLists.txt                               |  2 ++
 lldb/cmake/modules/AddLLDB.cmake                  |  8 +-------
 lldb/source/API/CMakeLists.txt                    |  2 ++
 lldb/source/Breakpoint/CMakeLists.txt             |  2 ++
 lldb/source/Core/CMakeLists.txt                   |  4 +++-
 lldb/source/DataFormatters/CMakeLists.txt         |  2 ++
 lldb/source/Expression/CMakeLists.txt             |  5 +++--
 lldb/source/Host/CMakeLists.txt                   |  2 ++
 lldb/source/Host/macosx/objcxx/CMakeLists.txt     |  2 ++
 lldb/source/Initialization/CMakeLists.txt         |  2 ++
 lldb/source/Interpreter/CMakeLists.txt            |  2 ++
 lldb/source/Interpreter/Interfaces/CMakeLists.txt |  2 ++
 lldb/source/Symbol/CMakeLists.txt                 |  2 ++
 lldb/source/Target/CMakeLists.txt                 |  2 ++
 lldb/source/Utility/CMakeLists.txt                |  2 ++
 lldb/source/ValueObject/CMakeLists.txt            |  3 ++-
 lldb/source/Version/CMakeLists.txt                | 15 +++++++--------
 17 files changed, 40 insertions(+), 19 deletions(-)

diff --git a/lldb/CMakeLists.txt b/lldb/CMakeLists.txt
index 85ba4fde17418..2aaf75dd87bc3 100644
--- a/lldb/CMakeLists.txt
+++ b/lldb/CMakeLists.txt
@@ -38,6 +38,8 @@ endif()
 include(LLDBConfig)
 include(AddLLDB)
 
+set(LLDB_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include)
+
 # Define the LLDB_CONFIGURATION_xxx matching the build type.
 if(uppercase_CMAKE_BUILD_TYPE STREQUAL "DEBUG" )
   add_definitions(-DLLDB_CONFIGURATION_DEBUG)
diff --git a/lldb/cmake/modules/AddLLDB.cmake b/lldb/cmake/modules/AddLLDB.cmake
index 3a9dcb79629b4..de9243b921745 100644
--- a/lldb/cmake/modules/AddLLDB.cmake
+++ b/lldb/cmake/modules/AddLLDB.cmake
@@ -71,12 +71,6 @@ function(add_lldb_library name)
     set_property(GLOBAL APPEND PROPERTY LLDB_PLUGINS ${name})
   endif()
 
-  if (MSVC_IDE OR XCODE)
-    string(REGEX MATCHALL "/[^/]+" split_path ${CMAKE_CURRENT_SOURCE_DIR})
-    list(GET split_path -1 dir)
-    file(GLOB_RECURSE headers
-      ../../include/lldb${dir}/*.h)
-  endif()
   if (PARAM_MODULE)
     set(libkind MODULE)
   elseif (PARAM_SHARED)
@@ -99,7 +93,7 @@ function(add_lldb_library name)
     set(pass_NO_INSTALL_RPATH NO_INSTALL_RPATH)
   endif()
 
-  llvm_add_library(${name} ${libkind} ${headers}
+  llvm_add_library(${name} ${libkind}
     ${PARAM_UNPARSED_ARGUMENTS}
     LINK_LIBS ${PARAM_LINK_LIBS}
     DEPENDS ${PARAM_DEPENDS}
diff --git a/lldb/source/API/CMakeLists.txt b/lldb/source/API/CMakeLists.txt
index 3bc569608e458..bddcf2f9922d0 100644
--- a/lldb/source/API/CMakeLists.txt
+++ b/lldb/source/API/CMakeLists.txt
@@ -125,6 +125,8 @@ add_lldb_library(liblldb SHARED ${option_framework}
   ${lldb_python_wrapper}
   ${lldb_lua_wrapper}
 
+  ADDITIONAL_HEADER_DIRS
+    ${LLDB_INCLUDE_DIR}/lldb/API
   DEPENDS
     lldb-sbapi-dwarf-enums
 
diff --git a/lldb/source/Breakpoint/CMakeLists.txt 
b/lldb/source/Breakpoint/CMakeLists.txt
index 6cd3c396a2c50..8ef3705750634 100644
--- a/lldb/source/Breakpoint/CMakeLists.txt
+++ b/lldb/source/Breakpoint/CMakeLists.txt
@@ -26,6 +26,8 @@ add_lldb_library(lldbBreakpoint NO_PLUGIN_DEPENDENCIES
   WatchpointOptions.cpp
   WatchpointResource.cpp
 
+  ADDITIONAL_HEADER_DIRS
+    ${LLDB_INCLUDE_DIR}/lldb/Breakpoint
   LINK_LIBS
     lldbCore
     lldbExpression
diff --git a/lldb/source/Core/CMakeLists.txt b/lldb/source/Core/CMakeLists.txt
index c4c442dcb2043..c95c40fb89eef 100644
--- a/lldb/source/Core/CMakeLists.txt
+++ b/lldb/source/Core/CMakeLists.txt
@@ -57,9 +57,11 @@ add_lldb_library(lldbCore NO_PLUGIN_DEPENDENCIES
   ThreadedCommunication.cpp
   UserSettingsController.cpp
   Value.cpp
+
+  ADDITIONAL_HEADER_DIRS
+    ${LLDB_INCLUDE_DIR}/lldb/Core
   DEPENDS
     clang-tablegen-targets
-
   LINK_LIBS
     lldbBreakpoint
     lldbDataFormatters
diff --git a/lldb/source/DataFormatters/CMakeLists.txt 
b/lldb/source/DataFormatters/CMakeLists.txt
index 91b10ba9e0ac8..e2bc5b40d72c0 100644
--- a/lldb/source/DataFormatters/CMakeLists.txt
+++ b/lldb/source/DataFormatters/CMakeLists.txt
@@ -18,6 +18,8 @@ add_lldb_library(lldbDataFormatters NO_PLUGIN_DEPENDENCIES
   ValueObjectPrinter.cpp
   VectorType.cpp
 
+  ADDITIONAL_HEADER_DIRS
+    ${LLDB_INCLUDE_DIR}/lldb/DataFormatters
   LINK_LIBS
     lldbCore
     lldbInterpreter
diff --git a/lldb/source/Expression/CMakeLists.txt 
b/lldb/source/Expression/CMakeLists.txt
index 9e1c341947e9d..3a18a83b9a5cd 100644
--- a/lldb/source/Expression/CMakeLists.txt
+++ b/lldb/source/Expression/CMakeLists.txt
@@ -17,9 +17,10 @@ add_lldb_library(lldbExpression NO_PLUGIN_DEPENDENCIES
   UserExpression.cpp
   UtilityFunction.cpp
 
+  ADDITIONAL_HEADER_DIRS
+    ${LLDB_INCLUDE_DIR}/lldb/Expression
   DEPENDS
-  intrinsics_gen
-
+    intrinsics_gen
   LINK_LIBS
     lldbCore
     lldbHost
diff --git a/lldb/source/Host/CMakeLists.txt b/lldb/source/Host/CMakeLists.txt
index 90814b1bed4c8..4eb4040250dee 100644
--- a/lldb/source/Host/CMakeLists.txt
+++ b/lldb/source/Host/CMakeLists.txt
@@ -176,6 +176,8 @@ endif()
 add_lldb_library(lldbHost NO_PLUGIN_DEPENDENCIES
   ${HOST_SOURCES}
 
+  ADDITIONAL_HEADER_DIRS
+    ${LLDB_INCLUDE_DIR}/lldb/Host
   LINK_LIBS
     lldbUtility
     ${EXTRA_LIBS}
diff --git a/lldb/source/Host/macosx/objcxx/CMakeLists.txt 
b/lldb/source/Host/macosx/objcxx/CMakeLists.txt
index cda8269ca9efd..18f894cb8b7e2 100644
--- a/lldb/source/Host/macosx/objcxx/CMakeLists.txt
+++ b/lldb/source/Host/macosx/objcxx/CMakeLists.txt
@@ -8,6 +8,8 @@ add_lldb_library(lldbHostMacOSXObjCXX NO_PLUGIN_DEPENDENCIES
   HostThreadMacOSX.mm
   MemoryMonitorMacOSX.mm
 
+  ADDITIONAL_HEADER_DIRS
+    ${LLDB_INCLUDE_DIR}/lldb/Host/macosx/objcxx
   LINK_LIBS
     lldbUtility
     ${EXTRA_LIBS}
diff --git a/lldb/source/Initialization/CMakeLists.txt 
b/lldb/source/Initialization/CMakeLists.txt
index b6282e162aa10..dde1f710ddd2c 100644
--- a/lldb/source/Initialization/CMakeLists.txt
+++ b/lldb/source/Initialization/CMakeLists.txt
@@ -11,6 +11,8 @@ add_lldb_library(lldbInitialization
   SystemInitializer.cpp
   SystemLifetimeManager.cpp
 
+  ADDITIONAL_HEADER_DIRS
+    ${LLDB_INCLUDE_DIR}/lldb/Initialization
   LINK_LIBS
     lldbCore
     lldbHost
diff --git a/lldb/source/Interpreter/CMakeLists.txt 
b/lldb/source/Interpreter/CMakeLists.txt
index 642263a8bda7f..1dd071b28946b 100644
--- a/lldb/source/Interpreter/CMakeLists.txt
+++ b/lldb/source/Interpreter/CMakeLists.txt
@@ -55,6 +55,8 @@ add_lldb_library(lldbInterpreter NO_PLUGIN_DEPENDENCIES
   Property.cpp
   ScriptInterpreter.cpp
 
+  ADDITIONAL_HEADER_DIRS
+    ${LLDB_INCLUDE_DIR}/lldb/Interpreter
   LINK_LIBS
     lldbInterpreterInterfaces
     lldbCommands
diff --git a/lldb/source/Interpreter/Interfaces/CMakeLists.txt 
b/lldb/source/Interpreter/Interfaces/CMakeLists.txt
index f44672aa50b75..072fcf4057329 100644
--- a/lldb/source/Interpreter/Interfaces/CMakeLists.txt
+++ b/lldb/source/Interpreter/Interfaces/CMakeLists.txt
@@ -1,6 +1,8 @@
 add_lldb_library(lldbInterpreterInterfaces NO_PLUGIN_DEPENDENCIES
   ScriptedInterfaceUsages.cpp
 
+  ADDITIONAL_HEADER_DIRS
+    ${LLDB_INCLUDE_DIR}/lldb/Interpreter/Interfaces
   LINK_LIBS
     lldbUtility
 
diff --git a/lldb/source/Symbol/CMakeLists.txt 
b/lldb/source/Symbol/CMakeLists.txt
index 86fa8583972b7..30a434ea2d351 100644
--- a/lldb/source/Symbol/CMakeLists.txt
+++ b/lldb/source/Symbol/CMakeLists.txt
@@ -33,6 +33,8 @@ add_lldb_library(lldbSymbol NO_PLUGIN_DEPENDENCIES
   Variable.cpp
   VariableList.cpp
 
+  ADDITIONAL_HEADER_DIRS
+    ${LLDB_INCLUDE_DIR}/lldb/Symbol
   LINK_LIBS
     lldbCore
     lldbExpression
diff --git a/lldb/source/Target/CMakeLists.txt 
b/lldb/source/Target/CMakeLists.txt
index d3545913a6902..7765331525340 100644
--- a/lldb/source/Target/CMakeLists.txt
+++ b/lldb/source/Target/CMakeLists.txt
@@ -82,6 +82,8 @@ add_lldb_library(lldbTarget
   UnwindLLDB.cpp
   VerboseTrapFrameRecognizer.cpp
 
+  ADDITIONAL_HEADER_DIRS
+    ${LLDB_INCLUDE_DIR}/lldb/Target
   LINK_LIBS
     lldbBreakpoint
     lldbCore
diff --git a/lldb/source/Utility/CMakeLists.txt 
b/lldb/source/Utility/CMakeLists.txt
index 6954a2508ffe1..51f3450b1c6e9 100644
--- a/lldb/source/Utility/CMakeLists.txt
+++ b/lldb/source/Utility/CMakeLists.txt
@@ -81,6 +81,8 @@ add_lldb_library(lldbUtility NO_INTERNAL_DEPENDENCIES
   XcodeSDK.cpp
   ZipFile.cpp
 
+  ADDITIONAL_HEADER_DIRS
+    ${LLDB_INCLUDE_DIR}/lldb/Utility
   LINK_LIBS
     ${LLDB_SYSTEM_LIBS}
     # lldbUtility does not depend on other LLDB libraries
diff --git a/lldb/source/ValueObject/CMakeLists.txt 
b/lldb/source/ValueObject/CMakeLists.txt
index 92683916f5a52..5cdc777c9d495 100644
--- a/lldb/source/ValueObject/CMakeLists.txt
+++ b/lldb/source/ValueObject/CMakeLists.txt
@@ -19,7 +19,8 @@ add_lldb_library(lldbValueObject
   ValueObjectVariable.cpp
   ValueObjectVTable.cpp
 
-
+  ADDITIONAL_HEADER_DIRS
+    ${LLDB_INCLUDE_DIR}/lldb/ValueObject
   LINK_LIBS
     lldbBreakpoint
     lldbDataFormatters
diff --git a/lldb/source/Version/CMakeLists.txt 
b/lldb/source/Version/CMakeLists.txt
index 90fe53d52cc5d..8b0acb9ef7550 100644
--- a/lldb/source/Version/CMakeLists.txt
+++ b/lldb/source/Version/CMakeLists.txt
@@ -21,9 +21,6 @@ add_custom_command(OUTPUT "${vcs_version_inc}"
                            
"-DLLVM_FORCE_VC_REPOSITORY=${LLVM_FORCE_VC_REPOSITORY}"
                            -P "${generate_vcs_version_script}")
 
-set_source_files_properties("${vcs_version_inc}"
-  PROPERTIES GENERATED TRUE
-             HEADER_FILE_ONLY TRUE)
 
 # Configure the Version.inc file.
 set(version_inc "${LLDB_BINARY_DIR}/include/lldb/Version/Version.inc")
@@ -32,13 +29,15 @@ configure_file(
   ${LLDB_SOURCE_DIR}/include/lldb/Version/Version.inc.in
   ${version_inc})
 
-set_source_files_properties("${version_inc}"
+set_source_files_properties(
+  "${vcs_version_inc}" "${version_inc}"
   PROPERTIES GENERATED TRUE
-             HEADER_FILE_ONLY TRUE)
-
+)
 include_directories(${CMAKE_CURRENT_BINARY_DIR})
 
 add_lldb_library(lldbVersion NO_PLUGIN_DEPENDENCIES
   Version.cpp
-  ${vcs_version_inc}
-  ${version_inc})
+  ADDITIONAL_HEADERS
+    ${version_inc}
+    ${vcs_version_inc}
+)

_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to