================
@@ -0,0 +1,86 @@
+# Based on 
https://gitlab.kitware.com/cmake/cmake/-/blob/3986f4b79ea6bf247eefad7ddb883cd6f65ac5c1/Modules/FindLibXml2.cmake
+# With support for using a static libxml2 library
+
+# use pkg-config to get the directories and then use these values
+# in the find_path() and find_library() calls
+find_package(PkgConfig QUIET)
+if(PkgConfig_FOUND)
+  pkg_check_modules(PC_LIBXML QUIET libxml-2.0)
+endif()
+
+find_path(LIBXML2_INCLUDE_DIR NAMES libxml/xpath.h
+  HINTS
+  ${PC_LIBXML_INCLUDEDIR}
+  ${PC_LIBXML_INCLUDE_DIRS}
+  PATH_SUFFIXES libxml2
+)
+
+if(DEFINED LIBXML2_LIBRARIES AND NOT DEFINED LIBXML2_LIBRARY)
+  set(LIBXML2_LIBRARY ${LIBXML2_LIBRARIES})
+endif()
+
+find_library(LIBXML2_SHARED_LIBRARY NAMES xml2 libxml2 libxml2_a
+  HINTS
+  ${PC_LIBXML_LIBDIR}
+  ${PC_LIBXML_LIBRARY_DIRS}
+)
+
+# This is a system lib on macOS, so we don't need to avoid the dependency
+if(APPLE)
+  set(LLVM_USE_STATIC_LIBXML2 OFF)
+endif()
----------------
petrhosek wrote:

I don't think this module should be making this decision, it should be up to to 
users/vendors. For example in case of our toolchain distribution we statically 
link (and LTO) libxml2 even on macOS and we want to have the control over which 
version is being used so this would be a regression to us.

https://github.com/llvm/llvm-project/pull/166867
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to