From 8ece1141e455d6643df0be885a5df200bdb3bc78 Mon Sep 17 00:00:00 2001 From: Rosen Penev Date: Thu, 30 Jul 2020 14:34:07 -0700 Subject: [PATCH] icu/meson: link against iconv when used externally This basically adds -liconv to LDFLAGS, fixing a linking issue when iconv is missing in the libc. The previous commit fixed finding iconv but did not fix linking. Switched to using c_compiler for iconv. It seems compiler does not work properly. Signed-off-by: Rosen Penev --- src/lib/icu/meson.build | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) --- a/src/lib/icu/meson.build +++ b/src/lib/icu/meson.build @@ -18,8 +18,18 @@ if icu_dep.found() 'Init.cxx', ] elif not get_option('iconv').disabled() - have_iconv = compiler.has_function('iconv', prefix : '#include ') - conf.set('HAVE_ICONV', have_iconv) + have_iconv = c_compiler.has_header_symbol('iconv.h', 'iconv') + if have_iconv + libiconv = c_compiler.find_library('iconv', required : false) + conf.set('HAVE_ICONV', have_iconv) + libiconv_dep = static_library('iconv', icu_sources, include_directories: inc, dependencies: libiconv) + icu_dep = declare_dependency(link_with: libiconv_dep, dependencies: util_dep) + endif + if not have_iconv and c_compiler.has_function('iconv') + libiconv = [] + have_iconv = true + conf.set('HAVE_ICONV', have_iconv) + endif if not have_iconv and get_option('iconv').enabled() error('iconv() not available') endif