[lldb/CMake] Only auto-enable Lua when SWIG is found
authorJonas Devlieghere <jonas@devlieghere.com>
Wed, 8 Jan 2020 22:01:57 +0000 (14:01 -0800)
committerJonas Devlieghere <jonas@devlieghere.com>
Wed, 8 Jan 2020 22:02:47 +0000 (14:02 -0800)
Just like Python, Lua should only be auto-enabled if SWIG is found as
well. This moves the logic of finding SWIG and Lua as a whole into a new
CMake package.

lldb/cmake/modules/FindLuaAndSwig.cmake [new file with mode: 0644]
lldb/cmake/modules/LLDBConfig.cmake

diff --git a/lldb/cmake/modules/FindLuaAndSwig.cmake b/lldb/cmake/modules/FindLuaAndSwig.cmake
new file mode 100644 (file)
index 0000000..2e99933
--- /dev/null
@@ -0,0 +1,31 @@
+#.rst:
+# FindLuaAndSwig
+# --------------
+#
+# Find Lua and SWIG as a whole.
+
+if(LUA_LIBRARIES AND LUA_INCLUDE_DIR AND SWIG_EXECUTABLE)
+  set(LUAANDSWIG_FOUND TRUE)
+else()
+  find_package(SWIG 2.0 QUIET)
+  if (SWIG_FOUND)
+    find_package(Lua QUIET)
+    if(LUA_FOUND AND SWIG_FOUND)
+      mark_as_advanced(
+        LUA_LIBRARIES
+        LUA_INCLUDE_DIR
+        SWIG_EXECUTABLE)
+    endif()
+  else()
+    message(STATUS "SWIG 2 or later is required for Lua support in LLDB but could not be found")
+  endif()
+
+  include(FindPackageHandleStandardArgs)
+  find_package_handle_standard_args(LuaAndSwig
+                                    FOUND_VAR
+                                      LUAANDSWIG_FOUND
+                                    REQUIRED_VARS
+                                      LUA_LIBRARIES
+                                      LUA_INCLUDE_DIR
+                                      SWIG_EXECUTABLE)
+endif()
index c4ec7fd..4a15a34 100644 (file)
@@ -56,7 +56,7 @@ endmacro()
 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" Lua LUA_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" PythonInterpAndLibs PYTHONINTERPANDLIBS_FOUND)
 add_optional_dependency(LLDB_ENABLE_LIBXML2 "Enable Libxml 2 support in LLDB" LibXml2 LIBXML2_FOUND VERSION 2.8)