meson: fix static build under Windows

Properly define GLIB/GOBJECT_STATIC_COMPILATION when static build is enabled.
Use library() instead of shared_library() to allow selecting static builds.

https://bugzilla.gnome.org/show_bug.cgi?id=784995
This commit is contained in:
Christoph Reiter 2017-07-16 16:41:02 +02:00 committed by Christoph Reiter
parent aa7c5cbdcb
commit cf93b27ceb
9 changed files with 16 additions and 9 deletions

View File

@ -724,7 +724,7 @@ else
gio_dtrace_hdr = []
endif
libgio = shared_library('gio-2.0',
libgio = library('gio-2.0',
gioenumtypes_h, gioenumtypes_c, gnetworking_h, gio_sources,
gio_dtrace_hdr, gio_dtrace_obj,
version : library_version,

View File

@ -14,7 +14,7 @@ gdbus_example_objectmanager_generated = custom_target('gdbus-example-objectmanag
'--generate-docbook', 'gdbus-example-objectmanager-generated',
'@INPUT@'])
libgdbus_example_objectmanager = shared_library('libgdbus-example-objectmanager',
libgdbus_example_objectmanager = library('libgdbus-example-objectmanager',
gdbus_example_objectmanager_generated,
c_args : ['-DHAVE_CONFIG_H=1'] + gio_c_args,
dependencies : [libglib_dep, libgmodule_dep, libgobject_dep, libgio_dep],

View File

@ -1,10 +1,10 @@
libtestmodulea = shared_library('testmodulea', 'test-module-a.c',
libtestmodulea = library('testmodulea', 'test-module-a.c',
install : false,
dependencies : [libglib_dep, libgobject_dep, libgmodule_dep, libgio_dep],
c_args : [ ]
)
libtestmoduleb = shared_library('testmoduleb', 'test-module-b.c',
libtestmoduleb = library('testmoduleb', 'test-module-b.c',
install : false,
dependencies : [libglib_dep, libgobject_dep, libgmodule_dep, libgio_dep],
c_args : [ ]

View File

@ -18,6 +18,9 @@
*/
#mesondefine GLIB_USING_SYSTEM_PRINTF
#mesondefine GLIB_STATIC_COMPILATION
#mesondefine GOBJECT_STATIC_COMPILATION
G_BEGIN_DECLS
#define G_MINFLOAT FLT_MIN
@ -115,7 +118,6 @@ typedef unsigned @glib_intptr_type_define@ guintptr;
#define GLIB_MICRO_VERSION @GLIB_MICRO_VERSION@
@glib_os@
@glib_static_compilation@
@glib_vacopy@

View File

@ -227,7 +227,7 @@ if use_pcre_static_flag
pcre_static_args = ['-DPCRE_STATIC']
endif
libglib = shared_library('glib-2.0',
libglib = library('glib-2.0',
glib_dtrace_obj, glib_dtrace_hdr,
sources : [deprecated_sources, glib_sources],
version : library_version,

View File

@ -95,7 +95,7 @@ if host_system == 'windows'
gmodule_sources += [gmodule_win_res]
endif
libgmodule = shared_library('gmodule-2.0',
libgmodule = library('gmodule-2.0',
sources : gmodule_sources,
version : library_version,
soversion : soversion,

View File

@ -61,7 +61,7 @@ else
gobject_dtrace_hdr = []
endif
libgobject = shared_library('gobject-2.0',
libgobject = library('gobject-2.0',
gobject_dtrace_obj, gobject_dtrace_hdr,
sources : gobject_sources,
version : library_version,

View File

@ -12,7 +12,7 @@ if host_system == 'windows'
gthread_sources += [gthread_win_res]
endif
libgthread = shared_library('gthread-2.0',
libgthread = library('gthread-2.0',
sources : gthread_sources,
version : library_version,
soversion : soversion,

View File

@ -123,6 +123,11 @@ if get_option('default_library') != 'static'
endif
endif
if host_system == 'windows' and get_option('default_library') == 'static'
glibconfig_conf.set('GLIB_STATIC_COMPILATION', '1')
glibconfig_conf.set('GOBJECT_STATIC_COMPILATION', '1')
endif
# FIXME: what about Cygwin (G_WITH_CYGWIN)
if host_system == 'windows'
glib_os = '''#define G_OS_WIN32