[Lldb-commits] [PATCH] D72290: [lldb/CMake] Use LLDB's autodetection logic for libxml2

Jonas Devlieghere via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Tue Jan 7 12:10:43 PST 2020


JDevlieghere updated this revision to Diff 236662.

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D72290/new/

https://reviews.llvm.org/D72290

Files:
  lldb/cmake/modules/FindLibXml28.cmake
  lldb/cmake/modules/LLDBConfig.cmake


Index: lldb/cmake/modules/LLDBConfig.cmake
===================================================================
--- lldb/cmake/modules/LLDBConfig.cmake
+++ lldb/cmake/modules/LLDBConfig.cmake
@@ -52,6 +52,7 @@
 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_PYTHON "Enable Python scripting support in LLDB" PythonInterpAndLibs PYTHONINTERPANDLIBS_FOUND)
+add_optional_dependency(LLDB_ENABLE_LIBXML2 "Enable Libxml 2 support in LLDB" LibXml28 LIBXML28_FOUND)
 
 option(LLDB_RELOCATABLE_PYTHON "Use the PYTHONHOME environment variable to locate Python." OFF)
 option(LLDB_USE_SYSTEM_SIX "Use six.py shipped with system and do not install a copy of it" OFF)
@@ -218,6 +219,11 @@
   include_directories(${LIBLZMA_INCLUDE_DIRS})
 endif()
 
+if (LLDB_ENABLE_LIBXML2)
+  list(APPEND system_libs ${LIBXML2_LIBRARIES})
+  include_directories(${LIBXML2_INCLUDE_DIR})
+endif()
+
 include_directories(BEFORE
   ${CMAKE_CURRENT_BINARY_DIR}/include
   ${CMAKE_CURRENT_SOURCE_DIR}/include
@@ -251,11 +257,7 @@
   endif()
 endif()
 
-if (NOT LIBXML2_FOUND)
-  find_package(LibXml2)
-endif()
-
-# Find libraries or frameworks that may be needed
+# Find Apple-specific libraries or frameworks that may be needed.
 if (APPLE)
   if(NOT IOS)
     find_library(CARBON_LIBRARY Carbon)
@@ -264,18 +266,13 @@
   find_library(FOUNDATION_LIBRARY Foundation)
   find_library(CORE_FOUNDATION_LIBRARY CoreFoundation)
   find_library(SECURITY_LIBRARY Security)
-  set(LLDB_ENABLE_LIBXML2 ON)
-  list(APPEND system_libs xml2
+  list(APPEND system_libs
        ${FOUNDATION_LIBRARY}
        ${CORE_FOUNDATION_LIBRARY}
        ${CORE_SERVICES_LIBRARY}
        ${SECURITY_LIBRARY}
        ${DEBUG_SYMBOLS_LIBRARY})
   include_directories(${LIBXML2_INCLUDE_DIR})
-elseif(LIBXML2_FOUND AND LIBXML2_VERSION_STRING VERSION_GREATER 2.8)
-  set(LLDB_ENABLE_LIBXML2 ON)
-  list(APPEND system_libs ${LIBXML2_LIBRARIES})
-  include_directories(${LIBXML2_INCLUDE_DIR})
 endif()
 
 if( WIN32 AND NOT CYGWIN )
Index: lldb/cmake/modules/FindLibXml28.cmake
===================================================================
--- /dev/null
+++ lldb/cmake/modules/FindLibXml28.cmake
@@ -0,0 +1,24 @@
+#.rst:
+# FindLibXml28
+# -----------
+#
+# Find a recent version (>2.8) of Libxml2.
+
+if(LIBXML2_LIBRARIES AND LIBXML2_INCLUDE_DIR)
+  set(LIBXML28_FOUND TRUE)
+else()
+  find_package(LibXml2 QUIET)
+
+  if(LIBXML2_FOUND AND LIBXML2_VERSION_STRING VERSION_GREATER 2.8)
+    mark_as_advanced(LIBXML2_LIBRARIES LIBXML2_INCLUDE_DIR)
+  endif()
+
+  include(FindPackageHandleStandardArgs)
+  find_package_handle_standard_args(LibXml28
+                                    FOUND_VAR
+                                      LIBXML28_FOUND
+                                    REQUIRED_VARS
+                                      LIBXML2_LIBRARIES
+                                      LIBXML2_INCLUDE_DIR)
+endif()
+


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D72290.236662.patch
Type: text/x-patch
Size: 3054 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20200107/8d37e44e/attachment.bin>


More information about the lldb-commits mailing list