[Lldb-commits] [lldb] build: enable CONFIG mode search for LibXml2 for LLDB (PR #117615)
via lldb-commits
lldb-commits at lists.llvm.org
Mon Nov 25 11:32:14 PST 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-lldb
Author: Saleem Abdulrasool (compnerd)
<details>
<summary>Changes</summary>
The `find_package(LibXml2 ...)` invocation that we are currently using precludes the use of "CONFIG mode" for libxml2. This is important to allow dependencies to flow through the build with static builds on Windows, which depends on Bcrypt and conditionally on Ws2_32 (in development - current releases are unconditionally dependent on it). If libxml2 is built statically, this dependency would need to be replicated into LLDB's build configuration to ensure that the dependencies are met.
Add a workaround to support CONFIG mode search which avoids this need. Additionally, clean up some unnecessary include paths. The use of `LibXml2::LibXml2` with `target_link_libraries` on `libLLDBHost` ensures that the header search path is properly propagated.
---
Full diff: https://github.com/llvm/llvm-project/pull/117615.diff
1 Files Affected:
- (modified) lldb/cmake/modules/LLDBConfig.cmake (+11-6)
``````````diff
diff --git a/lldb/cmake/modules/LLDBConfig.cmake b/lldb/cmake/modules/LLDBConfig.cmake
index 93ccd9c479c2b8..ba3ce6c444f887 100644
--- a/lldb/cmake/modules/LLDBConfig.cmake
+++ b/lldb/cmake/modules/LLDBConfig.cmake
@@ -57,7 +57,17 @@ add_optional_dependency(LLDB_ENABLE_CURSES "Enable curses support in LLDB" Curse
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 2.8)
+# LibXml2 is required if LLDB_ENABLE_LIBXML2 is ON or AUTO. The LibXml2 package
+# search is not setup properly to support the CONFIG mode search. Furthermore,
+# in CONFIG mode, we cannot specify the version as that is an exact match. As a
+# mitigation, perform a CONFIG mode search for LibXml2 if LLDB_ENABLE_LIBXML2
+# is ON or AUTO, and fallback to the old path if not found.
+if(LLDB_ENABLE_LIBXML2 OR "${LLDB_ENABLE_LIBXML2}" STREQUAL "AUTO")
+ find_package(LibXml2 CONFIG)
+ if(NOT TARGET LibXml2::LibXml2)
+ add_optional_dependency(LLDB_ENABLE_LIBXML2 "Enable Libxml 2 support in LLDB" LibXml2 LIBXML2_FOUND VERSION 2.8)
+ endif()
+endif()
add_optional_dependency(LLDB_ENABLE_FBSDVMCORE "Enable libfbsdvmcore support in LLDB" FBSDVMCore FBSDVMCore_FOUND QUIET)
option(LLDB_USE_ENTITLEMENTS "When codesigning, use entitlements if available" ON)
@@ -239,10 +249,6 @@ if (LLDB_ENABLE_LZMA)
include_directories(${LIBLZMA_INCLUDE_DIRS})
endif()
-if (LLDB_ENABLE_LIBXML2)
- include_directories(${LIBXML2_INCLUDE_DIR})
-endif()
-
include_directories(BEFORE
${CMAKE_CURRENT_BINARY_DIR}/include
${CMAKE_CURRENT_SOURCE_DIR}/include
@@ -283,7 +289,6 @@ if (APPLE)
find_library(FOUNDATION_LIBRARY Foundation)
find_library(CORE_FOUNDATION_LIBRARY CoreFoundation)
find_library(SECURITY_LIBRARY Security)
- include_directories(${LIBXML2_INCLUDE_DIR})
endif()
if( WIN32 AND NOT CYGWIN )
``````````
</details>
https://github.com/llvm/llvm-project/pull/117615
More information about the lldb-commits
mailing list