From 4b82738f0ada5f807145639082a8dc0c993bd41f Mon Sep 17 00:00:00 2001 From: Xavier Claessens Date: Tue, 15 May 2018 15:17:28 -0400 Subject: [PATCH] Meson: Add missing flags on Windows win32_cflags gets used globally as cflags and exposed in the .pc file. win32_ldflags gets passed to glib-2.0 and exposed in the .pc file. This should match what the autotools build is currently doing with GLIB_EXTRA_CFLAGS and G_LIBS_EXTRA. https://bugzilla.gnome.org/show_bug.cgi?id=784995 --- glib/meson.build | 6 +++--- meson.build | 17 ++++++++++++++++- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/glib/meson.build b/glib/meson.build index 410669dce..a97d11f6c 100644 --- a/glib/meson.build +++ b/glib/meson.build @@ -234,7 +234,7 @@ libglib = library('glib-2.0', soversion : soversion, install : true, # intl.lib is not compatible with SAFESEH - link_args : [noseh_link_args, glib_link_flags], + link_args : [noseh_link_args, glib_link_flags, win32_ldflags], include_directories : configinc, link_with : [charset_lib, gnulib_lib], dependencies : [pcre, thread_dep, libintl, librt] + libiconv + platform_deps, @@ -250,9 +250,9 @@ libglib_dep = declare_dependency( include_directories : [configinc, glibinc]) pkg.generate(libraries : [libglib, libintl], - libraries_private : [osx_ldflags], + libraries_private : [osx_ldflags, win32_ldflags], subdirs : ['glib-2.0'], - extra_cflags : ['-I${libdir}/glib-2.0/include'], + extra_cflags : ['-I${libdir}/glib-2.0/include'] + win32_cflags, variables : ['bindir=' + join_paths('${prefix}', get_option('bindir')), 'glib_genmarshal=' + join_paths('${bindir}', 'glib-genmarshal'), 'gobject_query=' + join_paths('${bindir}', 'gobject-query'), diff --git a/meson.build b/meson.build index f82a75a13..511b0393d 100644 --- a/meson.build +++ b/meson.build @@ -1765,7 +1765,22 @@ if libmount_dep.length() != 0 glib_conf.set('HAVE_LIBMOUNT', 1) endif glib_conf.set('GIO_MODULE_DIR', glib_giomodulesdir) -# FIXME: Missing: @G_LIBS_EXTRA@ @GLIB_EXTRA_CFLAGS@ @G_MODULE_LDFLAGS@ +# FIXME: Missing: @G_MODULE_LDFLAGS@ + +win32_cflags = [] +win32_ldflags = [] +if host_system == 'windows' and cc.get_id() != 'msvc' + # Ensure MSVC-compatible struct packing convention is used when + # compiling for Win32 with gcc. It is used for the whole project and exposed + # in glib-2.0.pc. + win32_cflags = ['-mms-bitfields'] + add_project_arguments(win32_cflags, language : 'c') + + # Win32 API libs, used only by libglib and exposed in glib-2.0.pc + win32_ldflags = ['-lws2_32', '-lole32', '-lwinmm', '-lshlwapi'] +elif host_system == 'cygwin' + win32_ldflags = ['-luser32', '-lkernel32'] +endif # Tracing: dtrace want_dtrace = get_option('dtrace')