[PATCH] D109975: [CMake] Consistently use the LibXml2::LibXml2 target instead of LIBXML2_LIBRARIES
Markus Böck via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Sep 17 09:07:34 PDT 2021
zero9178 created this revision.
zero9178 added reviewers: phosek, hans, MaskRay, compnerd.
Herald added subscribers: arphaman, mgorny.
zero9178 requested review of this revision.
Herald added projects: clang, LLDB.
Herald added subscribers: lldb-commits, cfe-commits.
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
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D109975
Files:
clang/tools/c-index-test/CMakeLists.txt
lldb/source/Host/CMakeLists.txt
Index: lldb/source/Host/CMakeLists.txt
===================================================================
--- lldb/source/Host/CMakeLists.txt
+++ lldb/source/Host/CMakeLists.txt
@@ -137,7 +137,7 @@
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})
Index: clang/tools/c-index-test/CMakeLists.txt
===================================================================
--- clang/tools/c-index-test/CMakeLists.txt
+++ clang/tools/c-index-test/CMakeLists.txt
@@ -40,12 +40,7 @@
# 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)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D109975.373241.patch
Type: text/x-patch
Size: 1159 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210917/78a521f5/attachment.bin>
More information about the cfe-commits
mailing list