meson: Use proxy-libintl if gettext is not found

This is a stub-only library that can be used while building against
MSVC and contains no i18n machinery at all.

The dependencies added indirectly use the libintl.h header, and when
built as a subproject, the header won't be in a path known the
pre-processor.
This commit is contained in:
Nirbheek Chauhan 2017-03-21 22:06:22 +05:30 committed by Matthias Clasen
parent fb1f52e32f
commit ee94ad776e
5 changed files with 23 additions and 15 deletions

View File

@ -755,7 +755,7 @@ executable('gio', gio_tool_sources,
c_args : ['-DHAVE_CONFIG_H=1'] + gio_c_args,
# intl.lib is not compatible with SAFESEH
link_args : noseh_link_args,
dependencies : [libgio_dep, libgobject_dep, libgmodule_dep, libglib_dep])
dependencies : [libintl, libgio_dep, libgobject_dep, libgmodule_dep, libglib_dep])
executable('gresource', 'gresource-tool.c',
install : true,

View File

@ -10,5 +10,6 @@ giowin32_sources = [
giowin32_lib = static_library('giowin32',
sources : [giowin32_sources, gioenumtypes_h],
include_directories : [configinc, glibinc, gioinc, gmoduleinc],
dependencies : [libintl],
pic : true,
c_args : [ '-DHAVE_CONFIG_H', '-DG_DISABLE_DEPRECATED' ] + gio_c_args)

View File

@ -233,24 +233,24 @@ if host_system == 'windows'
gui_app : true,
c_args : ['-DHAVE_CONFIG_H=1'],
include_directories : configinc,
dependencies : [libglib_dep])
dependencies : [libintl, libglib_dep])
executable('gspawn-win32-helper-console', 'gspawn-win32-helper.c',
install : true,
c_args : ['-DHAVE_CONFIG_H=1', '-DHELPER_CONSOLE'],
include_directories : configinc,
dependencies : [libglib_dep])
dependencies : [libintl, libglib_dep])
else
executable('gspawn-win64-helper', 'gspawn-win32-helper.c',
install : true,
gui_app : true,
c_args : ['-DHAVE_CONFIG_H=1'],
include_directories : configinc,
dependencies : [libglib_dep])
dependencies : [libintl, libglib_dep])
executable('gspawn-win64-helper-console', 'gspawn-win32-helper.c',
install : true,
c_args : ['-DHAVE_CONFIG_H=1', '-DHELPER_CONSOLE'],
include_directories : configinc,
dependencies : [libglib_dep])
dependencies : [libintl, libglib_dep])
endif
else
gtester = executable('gtester', 'gtester.c',

View File

@ -60,7 +60,7 @@ libgobject = shared_library('gobject-2.0',
soversion : soversion,
install : true,
include_directories : [configinc],
dependencies : [libffi_dep, libglib_dep],
dependencies : [libintl, libffi_dep, libglib_dep],
c_args : ['-DG_LOG_DOMAIN="GLib-GObject"', '-DGOBJECT_COMPILATION'] + glib_hidden_visibility_args)
libgobject_dep = declare_dependency(link_with : libgobject,

View File

@ -115,12 +115,6 @@ if get_option('default_library') != 'static'
endif
endif
if run_command('xgettext', '--help').returncode() != 0
error('GNU Gettext required currently.')
endif
glib_conf.set('HAVE_GETTEXT', 1)
glib_conf.set_quoted('GLIB_LOCALE_DIR', join_paths(glib_datadir, 'locale'))
# FIXME: what about Cygwin (G_WITH_CYGWIN)
if host_system == 'windows'
glib_os = '''#define G_OS_WIN32
@ -603,8 +597,6 @@ endif
# AC_FUNC_PRINTF_UNIX98
# Nothing uses HAVE_UNIX98_PRINTF
glib_conf.set('HAVE_DCGETTEXT', cc.has_header_symbol('libintl.h', 'dcgettext'))
# Check for nl_langinfo and CODESET
# FIXME: Check for HAVE_BIND_TEXTDOMAIN_CODESET
if cc.links('''#include <langinfo.h>
@ -1276,8 +1268,21 @@ glib_conf.set('USE_SYSTEM_PCRE', pcre.found())
libm = cc.find_library('m', required : false)
libffi_dep = dependency('libffi', version : '>= 3.0.0', fallback : ['libffi', 'ffi_dep'])
libz_dep = dependency('zlib', fallback : ['zlib', 'zlib_dep'])
# Only used on non-glibc targets
libintl = cc.find_library('intl', required : false)
if host_system == 'windows' and not libintl.found()
# Used only when the gettext library is not available (MSVC, not MinGW)
libintl = subproject('proxy-libintl').get_variable('intl_dep')
glib_conf.set('HAVE_DCGETTEXT', 1)
else
glib_conf.set('HAVE_DCGETTEXT', cc.has_header_symbol('libintl.h', 'dcgettext'))
endif
# We require gettext to always be present
glib_conf.set('HAVE_GETTEXT', 1)
glib_conf.set_quoted('GLIB_LOCALE_DIR', join_paths(glib_datadir, 'locale'))
# xgettext is optional (on Windows for instance)
xgettext = find_program('xgettext', required : false)
# libmount is only used by gio, but we need to fetch the libs to generate the
# pkg-config file below
@ -1382,7 +1387,9 @@ subdir('gobject')
subdir('gthread')
subdir('gmodule')
subdir('gio')
subdir('po')
if xgettext.found()
subdir('po')
endif
# Configure and install pkg-config files
pc_files = [