[grilo/master.msvc: 1/13] meson: Find libxml2 manually on MSVC builds



commit 1e6dbdd33ad7a496602648be85995b816ea84bda
Author: Chun-wei Fan <fanchunwei src gnome org>
Date:   Wed Apr 22 12:01:36 2020 +0800

    meson: Find libxml2 manually on MSVC builds
    
    The libxml2 build files for Visual Studio do not generate pkg-config files for
    us, so this update makes Meson search for it manually using cc.find_library()
    and also check we have libxml/parser.h.
    
    Also fix the pkg-config file that is being generated in this case, since we
    can't pass a manually-found library object to 'requires:'.
    
    This will require Meson 0.50.0 or later.

 meson.build     | 10 ++++++++--
 src/meson.build | 10 +++++++++-
 2 files changed, 17 insertions(+), 3 deletions(-)
---
diff --git a/meson.build b/meson.build
index 0c2005c..263cd66 100644
--- a/meson.build
+++ b/meson.build
@@ -13,7 +13,7 @@ project('grilo', 'c',
             'warning_level=1'
         ],
         license: 'LGPL 2.1',
-        meson_version: '>= 0.46.0')
+        meson_version: '>= 0.50.0')
 
 grilo_version = meson.project_version()
 grlnet_version = meson.project_version()
@@ -40,11 +40,17 @@ grl_name = '@0@-@1@'.format(meson.project_name(), grl_majorminor)
 glib2_required = '2.58'
 glib2_required_info = '>= @0@'.format(glib2_required)
 
+cc = meson.get_compiler('c')
+
 gio_dep = dependency('gio-2.0', version: glib2_required_info, required: true)
 glib_dep = dependency('glib-2.0', version: glib2_required_info, required: true)
 gmodule_dep = dependency('gmodule-2.0', version: glib2_required_info, required: true)
 gobject_dep = dependency('gobject-2.0', version: glib2_required_info, required: true)
-libxml_dep = dependency('libxml-2.0', required: true)
+libxml_dep = dependency('libxml-2.0', required: cc.get_argument_syntax() != 'msvc')
+
+if cc.get_argument_syntax() == 'msvc' and not libxml_dep.found()
+  libxml_dep = cc.find_library('libxml2', has_headers: [ 'libxml/parser.h' ])
+endif
 
 enable_grlnet = get_option('enable-grl-net')
 if enable_grlnet
diff --git a/src/meson.build b/src/meson.build
index 10fd390..c0e2103 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -89,10 +89,17 @@ c_args = [
     '-DHAVE_CONFIG_H',
 ]
 
+libgrl_dep_libs = []
 libgrl_deps = [
-    glib_dep, gobject_dep, gmodule_dep, gio_dep, libxml_dep
+    glib_dep, gobject_dep, gmodule_dep, gio_dep
 ]
 
+if libxml_dep.type_name() == 'pkgconfig'
+  libgrl_deps += libxml_dep
+elif libxml_dep.type_name() == 'library'
+  libgrl_dep_libs += libxml_dep
+endif
+
 libgrl = shared_library(grl_name,
     sources: grl_sources + grl_marshal + grl_type_builtins + grl_priv_headers,
     install: true,
@@ -110,6 +117,7 @@ libgrl_dep = declare_dependency(link_with: libgrl,
 grl_pc = pkgconfig.generate(libgrl,
     filebase: grl_name,
     requires: libgrl_deps,
+    libraries: libgrl_dep_libs,
     subdirs: grl_name,
     name: 'Grilo Framework',
     description: 'Grilo Framework for multimedia developers',


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