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)


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)
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to