[glib] meson/Windows: Check whether system PCRE is a static build



commit ea6ac5f71eefcfa98fdce130170ab15f8464219d
Author: Chun-wei Fan <fanchunwei src gnome org>
Date:   Tue Jul 25 16:28:29 2017 +0800

    meson/Windows: Check whether system PCRE is a static build
    
    Instead of hardcoding -DPCRE_STATIC into the CFLAGS of GLib, do the
    following on Windows only (since PCRE_STATIC only matters on Windows):
    
    -If there is no installed PCRE, use the included PCRE copy and
     enable -DPCRE_STATIC, as we did before.
    -If there is a installed PCRE, check whether the PCRE build is a static
     or DLL build by checking the linkage against pcre_free() with
     PCRE_STATIC defined works.  If it does, enable -DPCRE_STATIC.
    -On non-Windows builds, do not enable -DPCRE_STATIC
    
    https://bugzilla.gnome.org/show_bug.cgi?id=783270

 glib/meson.build |    8 +++++++-
 meson.build      |   21 +++++++++++++++++++++
 2 files changed, 28 insertions(+), 1 deletions(-)
---
diff --git a/glib/meson.build b/glib/meson.build
index 008d21f..67ed3f5 100644
--- a/glib/meson.build
+++ b/glib/meson.build
@@ -213,6 +213,12 @@ else
   glib_dtrace_hdr = []
 endif
 
+pcre_static_args = []
+
+if use_pcre_static_flag
+  pcre_static_args = ['-DPCRE_STATIC']
+endif
+
 libglib = shared_library('glib-2.0',
   glib_dtrace_obj, glib_dtrace_hdr,
   sources : [deprecated_sources, glib_sources, thread_src, plat_src],
@@ -224,7 +230,7 @@ libglib = shared_library('glib-2.0',
   include_directories : configinc,
   link_with : [charset_lib, gnulib_lib],
   dependencies : [pcre, thread_dep, libintl, librt] + libiconv + platform_deps,
-  c_args : ['-DG_LOG_DOMAIN="GLib"', '-DGLIB_COMPILATION', '-DPCRE_STATIC'] + glib_hidden_visibility_args
+  c_args : ['-DG_LOG_DOMAIN="GLib"', '-DGLIB_COMPILATION'] + pcre_static_args + glib_hidden_visibility_args
 )
 
 libglib_dep = declare_dependency(link_with : libglib,
diff --git a/meson.build b/meson.build
index 4019f62..3cd2fbe 100644
--- a/meson.build
+++ b/meson.build
@@ -1391,6 +1391,27 @@ else
 endif
 glib_conf.set('USE_SYSTEM_PCRE', use_system_pcre)
 
+use_pcre_static_flag = false
+
+if host_system == 'windows'
+  if not use_system_pcre
+    use_pcre_static_flag = true
+  else
+    pcre_static = cc.links('''#define PCRE_STATIC
+                              #include <pcre.h>
+                              int main() {
+                                void *p = NULL;
+                                pcre_free(p);
+                                return 0;
+                              }''',
+                           dependencies: pcre,
+                           name : 'Windows system PCRE is a static build')
+    if pcre_static
+      use_pcre_static_flag = true
+    endif
+  endif
+endif
+
 libm = cc.find_library('m', required : false)
 libffi_dep = dependency('libffi', version : '>= 3.0.0', fallback : ['libffi', 'ffi_dep'])
 zlib_libname = '-lz'


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