[CMake] Consistently use the LibXml2::LibXml2 target instead of LIBXML2_LIBRARIES

Linking against the LibXml2::LibXml2 target has the advantage of not only importing the library, but also adding the include path as well as any definitions the library requires. In case of a static build of libxml2, eg. a define is set on Windows to remove any DLL imports and export.

LLVM already makes use of the target, but c-index-test and lldb were still linking against the library only.

The workaround for Mac OS-X that I removed seems to have also been made redundant since https://reviews.llvm.org/D84563 I believe

Differential Revision: https://reviews.llvm.org/D109975
This commit is contained in:
Markus Böck 2021-09-25 13:13:11 +02:00
parent ee267b1c7c
commit 0b61f43b60
2 changed files with 2 additions and 7 deletions

View File

@ -40,12 +40,7 @@ set_target_properties(c-index-test
# If libxml2 is available, make it available for c-index-test.
if (CLANG_HAVE_LIBXML)
if ((CMAKE_OSX_SYSROOT) AND (EXISTS ${CMAKE_OSX_SYSROOT}/${LIBXML2_INCLUDE_DIR}))
include_directories(SYSTEM ${CMAKE_OSX_SYSROOT}/${LIBXML2_INCLUDE_DIR})
else()
include_directories(SYSTEM ${LIBXML2_INCLUDE_DIR})
endif()
target_link_libraries(c-index-test PRIVATE ${LIBXML2_LIBRARIES})
target_link_libraries(c-index-test PRIVATE LibXml2::LibXml2)
endif()
if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)

View File

@ -137,7 +137,7 @@ if (CMAKE_SYSTEM_NAME MATCHES "NetBSD")
list(APPEND EXTRA_LIBS kvm)
endif()
if (LLDB_ENABLE_LIBXML2)
list(APPEND EXTRA_LIBS ${LIBXML2_LIBRARIES})
list(APPEND EXTRA_LIBS LibXml2::LibXml2)
endif()
if (HAVE_LIBDL)
list(APPEND EXTRA_LIBS ${CMAKE_DL_LIBS})