[Lldb-commits] [lldb] 327153d - [lldb][cmake] Accept config-mode packages in add_optional_dependency (#222976)

via lldb-commits lldb-commits at lists.llvm.org
Wed Sep 16 02:15:21 PDT 2026


Author: Charles Zablit
Date: 2026-09-16T10:15:15+01:00
New Revision: 327153dcd71bbec2fa827b84fa513c7c6cf88ce0

URL: https://github.com/llvm/llvm-project/commit/327153dcd71bbec2fa827b84fa513c7c6cf88ce0
DIFF: https://github.com/llvm/llvm-project/commit/327153dcd71bbec2fa827b84fa513c7c6cf88ce0.diff

LOG: [lldb][cmake] Accept config-mode packages in add_optional_dependency (#222976)

`add_optional_dependency` copies the caller-supplied `<found>` variable
after `find_package`, and callers name the Find module's result
variable, which is usually all-caps (`LIBXML2_FOUND`, `CURSES_FOUND`). A
package located in config mode only sets `<PackageName>_FOUND`
(`LibXml2_FOUND`), so the copy comes back empty and the dependency is
reported as missing and silently disabled even though `find_package`
succeeded.

Set the result variable to TRUE when either `${found}` or
`${package}_FOUND` is set, FALSE otherwise.

Behavior for module-mode finds is unchanged; only the config-mode case,
which previously always evaluated to false, is affected.

Added: 
    

Modified: 
    lldb/cmake/modules/FindCursesAndPanel.cmake
    lldb/cmake/modules/FindLuaAndSwig.cmake
    lldb/cmake/modules/FindPythonAndSwig.cmake
    lldb/cmake/modules/LLDBConfig.cmake

Removed: 
    


################################################################################
diff  --git a/lldb/cmake/modules/FindCursesAndPanel.cmake b/lldb/cmake/modules/FindCursesAndPanel.cmake
index 5e13a1b79ecf9..982da7c184742 100644
--- a/lldb/cmake/modules/FindCursesAndPanel.cmake
+++ b/lldb/cmake/modules/FindCursesAndPanel.cmake
@@ -25,7 +25,7 @@ if(CURSES_INCLUDE_DIRS AND CURSES_LIBRARIES AND PANEL_LIBRARIES)
     endif()
     mark_as_advanced(CURSES_HAS_TINFO)
   endif()
-  set(CURSESANDPANEL_FOUND TRUE)
+  set(CursesAndPanel_FOUND TRUE)
 else()
   find_package(Curses QUIET)
   find_library(PANEL_LIBRARIES NAMES panel DOC "The curses panel library" QUIET)
@@ -48,7 +48,7 @@ else()
 
   find_package_handle_standard_args(CursesAndPanel
                                     FOUND_VAR
-                                      CURSESANDPANEL_FOUND
+                                      CursesAndPanel_FOUND
                                     REQUIRED_VARS
                                       CURSES_INCLUDE_DIRS
                                       CURSES_LIBRARIES

diff  --git a/lldb/cmake/modules/FindLuaAndSwig.cmake b/lldb/cmake/modules/FindLuaAndSwig.cmake
index c5df29e8d0a92..5235fcdf8cdde 100644
--- a/lldb/cmake/modules/FindLuaAndSwig.cmake
+++ b/lldb/cmake/modules/FindLuaAndSwig.cmake
@@ -5,7 +5,7 @@
 # Find Lua and SWIG as a whole.
 
 if(LUA_LIBRARIES AND LUA_INCLUDE_DIR AND LLDB_ENABLE_SWIG)
-  set(LUAANDSWIG_FOUND TRUE)
+  set(LuaAndSwig_FOUND TRUE)
 else()
   if (LLDB_ENABLE_SWIG)
     find_package(Lua 5.3)
@@ -32,7 +32,7 @@ else()
   include(FindPackageHandleStandardArgs)
   find_package_handle_standard_args(LuaAndSwig
                                     FOUND_VAR
-                                      LUAANDSWIG_FOUND
+                                      LuaAndSwig_FOUND
                                     REQUIRED_VARS
                                       LUA_EXECUTABLE
                                       LUA_LIBRARIES

diff  --git a/lldb/cmake/modules/FindPythonAndSwig.cmake b/lldb/cmake/modules/FindPythonAndSwig.cmake
index ce6d684787ffd..79afd747b0bb9 100644
--- a/lldb/cmake/modules/FindPythonAndSwig.cmake
+++ b/lldb/cmake/modules/FindPythonAndSwig.cmake
@@ -37,7 +37,7 @@ macro(FindPython3)
 endmacro()
 
 if(Python3_LIBRARIES AND Python3_INCLUDE_DIRS AND Python3_EXECUTABLE AND LLDB_ENABLE_SWIG)
-  set(PYTHONANDSWIG_FOUND TRUE)
+  set(PythonAndSwig_FOUND TRUE)
 else()
   if (LLDB_ENABLE_SWIG)
     FindPython3()
@@ -59,7 +59,7 @@ else()
   include(FindPackageHandleStandardArgs)
   find_package_handle_standard_args(PythonAndSwig
                                     FOUND_VAR
-                                      PYTHONANDSWIG_FOUND
+                                      PythonAndSwig_FOUND
                                     REQUIRED_VARS
                                       Python3_LIBRARIES
                                       Python3_INCLUDE_DIRS
@@ -69,7 +69,7 @@ endif()
 
 if (WIN32)
   set(LLDB_REQUIRED_PYTHON "3.11")
-  if(PYTHONANDSWIG_FOUND AND "${Python3_VERSION}" VERSION_LESS "${LLDB_REQUIRED_PYTHON}")
+  if(PythonAndSwig_FOUND AND "${Python3_VERSION}" VERSION_LESS "${LLDB_REQUIRED_PYTHON}")
     message(ERROR "Using Python ${Python3_VERSION}. Python ${LLDB_REQUIRED_PYTHON}+ is required.")
   endif()
 endif()

diff  --git a/lldb/cmake/modules/LLDBConfig.cmake b/lldb/cmake/modules/LLDBConfig.cmake
index 4859609d4f5a9..1f9a4e68b7737 100644
--- a/lldb/cmake/modules/LLDBConfig.cmake
+++ b/lldb/cmake/modules/LLDBConfig.cmake
@@ -18,7 +18,7 @@ if(CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR)
     "`CMakeFiles'. Please delete them.")
 endif()
 
-macro(add_optional_dependency variable description package found)
+macro(add_optional_dependency variable description package)
   cmake_parse_arguments(ARG
     "QUIET"
     "VERSION"
@@ -45,7 +45,7 @@ macro(add_optional_dependency variable description package found)
       set(maybe_quiet QUIET)
     endif()
     find_package(${package} ${ARG_VERSION} ${maybe_required} ${maybe_quiet})
-    set(${variable} "${${found}}")
+    set(${variable} "${${package}_FOUND}")
   endif()
 
   message(STATUS "${description}: ${${variable}}")
@@ -56,14 +56,14 @@ set(LLDB_LIBXML2_VERSION "2.8" CACHE STRING
   static builds of libxml 2. Use at your own risk.")
 mark_as_advanced(LLDB_LIBXML2_VERSION)
 
-add_optional_dependency(LLDB_ENABLE_SWIG "Enable SWIG to generate LLDB bindings" SWIG SWIG_FOUND VERSION 4)
-add_optional_dependency(LLDB_ENABLE_LIBEDIT "Enable editline support in LLDB" LibEdit LibEdit_FOUND)
-add_optional_dependency(LLDB_ENABLE_CURSES "Enable curses support in LLDB" CursesAndPanel CURSESANDPANEL_FOUND)
-add_optional_dependency(LLDB_ENABLE_LZMA "Enable LZMA compression support in LLDB" LibLZMA LIBLZMA_FOUND)
-add_optional_dependency(LLDB_ENABLE_LUA "Enable Lua scripting support in LLDB" LuaAndSwig LUAANDSWIG_FOUND)
-add_optional_dependency(LLDB_ENABLE_PYTHON "Enable Python scripting support in LLDB" PythonAndSwig PYTHONANDSWIG_FOUND)
-add_optional_dependency(LLDB_ENABLE_LIBXML2 "Enable Libxml 2 support in LLDB" LibXml2 LIBXML2_FOUND VERSION ${LLDB_LIBXML2_VERSION})
-add_optional_dependency(LLDB_ENABLE_TREESITTER "Enable Tree-sitter syntax highlighting" TreeSitter TREESITTER_FOUND)
+add_optional_dependency(LLDB_ENABLE_SWIG "Enable SWIG to generate LLDB bindings" SWIG VERSION 4)
+add_optional_dependency(LLDB_ENABLE_LIBEDIT "Enable editline support in LLDB" LibEdit)
+add_optional_dependency(LLDB_ENABLE_CURSES "Enable curses support in LLDB" CursesAndPanel)
+add_optional_dependency(LLDB_ENABLE_LZMA "Enable LZMA compression support in LLDB" LibLZMA)
+add_optional_dependency(LLDB_ENABLE_LUA "Enable Lua scripting support in LLDB" LuaAndSwig)
+add_optional_dependency(LLDB_ENABLE_PYTHON "Enable Python scripting support in LLDB" PythonAndSwig)
+add_optional_dependency(LLDB_ENABLE_LIBXML2 "Enable Libxml 2 support in LLDB" LibXml2 VERSION ${LLDB_LIBXML2_VERSION})
+add_optional_dependency(LLDB_ENABLE_TREESITTER "Enable Tree-sitter syntax highlighting" TreeSitter)
 
 option(LLDB_USE_ENTITLEMENTS "When codesigning, use entitlements if available" ON)
 option(LLDB_BUILD_FRAMEWORK "Build LLDB.framework (Darwin only)" OFF)


        


More information about the lldb-commits mailing list