From cc557c4d60f0b6545c6720ac0b11ddf03b1e5670 Mon Sep 17 00:00:00 2001 From: Rosen Penev Date: Tue, 19 Jul 2022 15:11:59 -0700 Subject: [PATCH] meson: port ncpmc iconv solution Properly deals with iconv, unlike the current solution. have_iconv fails when libiconv CFLAGS are passed to the compiler. Tested under OpenWrt with its CONFIG_BUILD_NLS, which adds libiconv include flags. Signed-off-by: Rosen Penev --- NEWS | 1 + src/lib/icu/meson.build | 28 ++++++++++++++++++---------- 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/NEWS b/NEWS index 60016adfa..76fe8a886 100644 --- a/NEWS +++ b/NEWS @@ -1,6 +1,7 @@ ver 0.23.9 (not yet released) * output - pipewire: set app icon +* improve iconv detection ver 0.23.8 (2022/07/09) * storage diff --git a/src/lib/icu/meson.build b/src/lib/icu/meson.build index 6e489876b..92f9e6b1f 100644 --- a/src/lib/icu/meson.build +++ b/src/lib/icu/meson.build @@ -18,17 +18,25 @@ if icu_dep.found() 'Util.cxx', 'Init.cxx', ] -elif not get_option('iconv').disabled() - # an installed iconv library will make the builtin iconv() unavailable, - # so search for the library first and pass it as (possible) dependency - iconv_dep = compiler.find_library('libiconv', required: false) - have_iconv = compiler.has_function('iconv', - dependencies: iconv_dep, - prefix : '#include ') - if not have_iconv and get_option('iconv').enabled() - error('iconv() not available') +else + if meson.version().version_compare('>= 0.60') + iconv_dep = dependency('iconv', required: get_option('iconv')) + conf.set('HAVE_ICONV', iconv_dep.found()) + elif not get_option('iconv').disabled() + iconv_open_snippet = '''#include + int main() { + iconv_open("",""); + }''' + have_iconv = compiler.links(iconv_open_snippet, name: 'iconv_open') + if not have_iconv + iconv_dep = compiler.find_library('iconv', required: false) + have_iconv = compiler.links(iconv_open_snippet, dependencies: iconv_dep, name: 'iconv_open') + endif + if not have_iconv and get_option('iconv').enabled() + error('iconv() not available') + endif + conf.set('HAVE_ICONV', have_iconv) endif - conf.set('HAVE_ICONV', have_iconv) endif icu = static_library(