mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-08-09 18:54:04 +02:00
meson: Fix underlinking of static libintl by trying iconv and pthread
I thought about checking for an intl pkg-config file but upstream are not interested in adding one so there seems little point. Closes #1851
This commit is contained in:
committed by
Philip Withnall
parent
842dccfce7
commit
56271ff271
@@ -356,19 +356,19 @@ libglib = library('glib-2.0',
|
|||||||
# intl.lib is not compatible with SAFESEH
|
# intl.lib is not compatible with SAFESEH
|
||||||
link_args : [noseh_link_args, glib_link_flags, win32_ldflags],
|
link_args : [noseh_link_args, glib_link_flags, win32_ldflags],
|
||||||
include_directories : configinc,
|
include_directories : configinc,
|
||||||
dependencies : pcre_deps + [thread_dep, libintl, librt] + libiconv + platform_deps + gnulib_libm_dependency,
|
dependencies : pcre_deps + [thread_dep, librt] + libintl_deps + libiconv + platform_deps + gnulib_libm_dependency,
|
||||||
c_args : glib_c_args,
|
c_args : glib_c_args,
|
||||||
objc_args : glib_c_args,
|
objc_args : glib_c_args,
|
||||||
)
|
)
|
||||||
|
|
||||||
libglib_dep = declare_dependency(
|
libglib_dep = declare_dependency(
|
||||||
link_with : libglib,
|
link_with : libglib,
|
||||||
dependencies : libintl,
|
dependencies : libintl_deps,
|
||||||
# We sadly need to export configinc here because everyone includes <glib/*.h>
|
# We sadly need to export configinc here because everyone includes <glib/*.h>
|
||||||
include_directories : [configinc, glibinc])
|
include_directories : [configinc, glibinc])
|
||||||
|
|
||||||
pkg.generate(libglib,
|
pkg.generate(libglib,
|
||||||
libraries : [libintl],
|
libraries : [libintl_deps],
|
||||||
libraries_private : [osx_ldflags, win32_ldflags],
|
libraries_private : [osx_ldflags, win32_ldflags],
|
||||||
subdirs : ['glib-2.0'],
|
subdirs : ['glib-2.0'],
|
||||||
extra_cflags : ['-I${libdir}/glib-2.0/include'] + win32_cflags,
|
extra_cflags : ['-I${libdir}/glib-2.0/include'] + win32_cflags,
|
||||||
|
27
meson.build
27
meson.build
@@ -1926,17 +1926,40 @@ endif
|
|||||||
# proxy-libintl subproject.
|
# proxy-libintl subproject.
|
||||||
# FIXME: glib-gettext.m4 has much more checks to detect broken/uncompatible
|
# FIXME: glib-gettext.m4 has much more checks to detect broken/uncompatible
|
||||||
# implementations. This could be extended if issues are found in some platforms.
|
# implementations. This could be extended if issues are found in some platforms.
|
||||||
|
libintl_deps = []
|
||||||
if cc.has_function('ngettext')
|
if cc.has_function('ngettext')
|
||||||
libintl = []
|
|
||||||
have_bind_textdomain_codeset = cc.has_function('bind_textdomain_codeset')
|
have_bind_textdomain_codeset = cc.has_function('bind_textdomain_codeset')
|
||||||
else
|
else
|
||||||
|
# First just find the bare library.
|
||||||
libintl = cc.find_library('intl', required : false)
|
libintl = cc.find_library('intl', required : false)
|
||||||
|
# The bare library probably won't link without help if it's static.
|
||||||
|
if libintl.found() and not cc.has_function('ngettext', dependencies : libintl)
|
||||||
|
libintl_iconv = cc.find_library('iconv', required : false)
|
||||||
|
# libintl supports different threading APIs, which may not
|
||||||
|
# require additional flags, but it defaults to using pthreads if
|
||||||
|
# found. Meson's "threads" dependency does not allow you to
|
||||||
|
# prefer pthreads. We may not be using pthreads for glib itself
|
||||||
|
# either so just link the library to satisfy libintl rather than
|
||||||
|
# also defining the macros with the -pthread flag.
|
||||||
|
libintl_pthread = cc.find_library('pthread', required : false)
|
||||||
|
# Try linking with just libiconv.
|
||||||
|
if libintl_iconv.found() and cc.has_function('ngettext', dependencies : [libintl, libintl_iconv])
|
||||||
|
libintl_deps += [libintl_iconv]
|
||||||
|
# Then also try linking with pthreads.
|
||||||
|
elif libintl_iconv.found() and libintl_pthread.found() and cc.has_function('ngettext', dependencies : [libintl, libintl_iconv, libintl_pthread])
|
||||||
|
libintl_deps += [libintl_iconv, libintl_pthread]
|
||||||
|
else
|
||||||
|
libintl = disabler()
|
||||||
|
endif
|
||||||
|
endif
|
||||||
if not libintl.found()
|
if not libintl.found()
|
||||||
libintl = subproject('proxy-libintl').get_variable('intl_dep')
|
libintl = subproject('proxy-libintl').get_variable('intl_dep')
|
||||||
|
libintl_deps = [libintl] + libintl_deps
|
||||||
have_bind_textdomain_codeset = true # proxy-libintl supports it
|
have_bind_textdomain_codeset = true # proxy-libintl supports it
|
||||||
else
|
else
|
||||||
|
libintl_deps = [libintl] + libintl_deps
|
||||||
have_bind_textdomain_codeset = cc.has_function('bind_textdomain_codeset',
|
have_bind_textdomain_codeset = cc.has_function('bind_textdomain_codeset',
|
||||||
dependencies : libintl)
|
dependencies : libintl_deps)
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user