[gtksourceview/meson.msvc: 1/8] meson.build: Manually search for libxml2 on MSVC if needed



commit 5b7386ddd9f913db9886b559740d570f6e89684a
Author: Chun-wei Fan <fanchunwei src gnome org>
Date:   Wed Apr 24 11:34:31 2019 +0800

    meson.build: Manually search for libxml2 on MSVC if needed
    
    The NMake Makefiles that come with libxml2 do not generate pkg-config
    files for us, so we need to look for the libxml2 headers and lib's
    manually if necessary on Visual Studio builds.

 meson.build | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)
---
diff --git a/meson.build b/meson.build
index 7405bd2b..d3eb08bf 100644
--- a/meson.build
+++ b/meson.build
@@ -74,7 +74,7 @@ glib_dep = dependency('glib-2.0', version: glib_req)
 gobject_dep = dependency('gobject-2.0', version: glib_req)
 gio_dep = dependency('gio-2.0', version: glib_req)
 gtk_dep = dependency('gtk+-3.0', version: gtk_req)
-libxml_dep = dependency('libxml-2.0', version: libxml_req)
+libxml_dep = dependency('libxml-2.0', version: libxml_req, required: cc.get_id() != 'msvc')
 
 gtk_quartz_dep = dependency('gtk+-quartz-3.0', version: gtk_doc_req, required: false)
 
@@ -102,6 +102,23 @@ else
   gtk_doc_dep = []
 endif
 
+# Look for the libxml2 library manually on Visual Studio if
+# its pkg-config file could not be found, as the NMake
+# Makefiles of libxml2 do not generate the pkg-config files
+# for us.  Remove once Meson gains the ability to declare
+# deps in a declarative way
+if cc.get_id() == 'msvc' and not libxml_dep.found()
+  libxml_headers = ['xmlreader', 'parser']
+  libxml_headers_missing = false
+  foreach h: libxml_headers
+    if not cc.has_header('libxml/@0@.h'.format(h))
+      libxml_headers_missing = true
+    endif
+  endforeach
+  assert(not libxml_headers_missing, 'The libxml2 headers and libs are required')
+  libxml_dep = cc.find_library('libxml2')
+endif
+
 xmllint_prg = find_program('xmllint', required: false)
 
 # Configurations


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]