Skip to content

Commit 733687b

Browse files
committed
build: enable CONFIG mode search for LibXml2 for LLDB
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.
1 parent fe3c23b commit 733687b

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

lldb/cmake/modules/LLDBConfig.cmake

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,17 @@ add_optional_dependency(LLDB_ENABLE_CURSES "Enable curses support in LLDB" Curse
5757
add_optional_dependency(LLDB_ENABLE_LZMA "Enable LZMA compression support in LLDB" LibLZMA LIBLZMA_FOUND)
5858
add_optional_dependency(LLDB_ENABLE_LUA "Enable Lua scripting support in LLDB" LuaAndSwig LUAANDSWIG_FOUND)
5959
add_optional_dependency(LLDB_ENABLE_PYTHON "Enable Python scripting support in LLDB" PythonAndSwig PYTHONANDSWIG_FOUND)
60-
add_optional_dependency(LLDB_ENABLE_LIBXML2 "Enable Libxml 2 support in LLDB" LibXml2 LIBXML2_FOUND VERSION 2.8)
60+
# LibXml2 is required if LLDB_ENABLE_LIBXML2 is ON or AUTO. The LibXml2 package
61+
# search is not setup properly to support the CONFIG mode search. Furthermore,
62+
# in CONFIG mode, we cannot specify the version as that is an exact match. As a
63+
# mitigation, perform a CONFIG mode search for LibXml2 if LLDB_ENABLE_LIBXML2
64+
# is ON or AUTO, and fallback to the old path if not found.
65+
if(LLDB_ENABLE_LIBXML2 OR "${LLDB_ENABLE_LIBXML2}" STREQUAL "AUTO")
66+
find_package(LibXml2 CONFIG)
67+
if(NOT TARGET LibXml2::LibXml2)
68+
add_optional_dependency(LLDB_ENABLE_LIBXML2 "Enable Libxml 2 support in LLDB" LibXml2 LIBXML2_FOUND VERSION 2.8)
69+
endif()
70+
endif()
6171
add_optional_dependency(LLDB_ENABLE_FBSDVMCORE "Enable libfbsdvmcore support in LLDB" FBSDVMCore FBSDVMCore_FOUND QUIET)
6272

6373
option(LLDB_USE_ENTITLEMENTS "When codesigning, use entitlements if available" ON)
@@ -239,10 +249,6 @@ if (LLDB_ENABLE_LZMA)
239249
include_directories(${LIBLZMA_INCLUDE_DIRS})
240250
endif()
241251

242-
if (LLDB_ENABLE_LIBXML2)
243-
include_directories(${LIBXML2_INCLUDE_DIR})
244-
endif()
245-
246252
include_directories(BEFORE
247253
${CMAKE_CURRENT_BINARY_DIR}/include
248254
${CMAKE_CURRENT_SOURCE_DIR}/include
@@ -283,7 +289,6 @@ if (APPLE)
283289
find_library(FOUNDATION_LIBRARY Foundation)
284290
find_library(CORE_FOUNDATION_LIBRARY CoreFoundation)
285291
find_library(SECURITY_LIBRARY Security)
286-
include_directories(${LIBXML2_INCLUDE_DIR})
287292
endif()
288293

289294
if( WIN32 AND NOT CYGWIN )

0 commit comments

Comments
 (0)