From 30fe76b17cc5aad395eb8a8a3da59e377a0b3d8e Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Thu, 15 Oct 2020 13:26:50 -0400 Subject: [PATCH] meson: cleanup curses/iconv test Skip the test if it is system emulation is not requested, and differentiate errors for lack of iconv and lack of curses. Signed-off-by: Paolo Bonzini --- meson.build | 85 ++++++++++++++++++++++++++++------------------------- 1 file changed, 45 insertions(+), 40 deletions(-) diff --git a/meson.build b/meson.build index c1c45e9845..15732f4701 100644 --- a/meson.build +++ b/meson.build @@ -455,40 +455,40 @@ if targetos == 'linux' and have_tools and not get_option('mpath').disabled() endif iconv = not_found -if not get_option('iconv').disabled() - libiconv = cc.find_library('iconv', - required: false, - static: enable_static) - if cc.links(''' - #include - int main(void) { - iconv_t conv = iconv_open("WCHAR_T", "UCS-2"); - return conv != (iconv_t) -1; - }''', dependencies: [libiconv]) - iconv = declare_dependency(dependencies: [libiconv]) - endif -endif -if get_option('iconv').enabled() and not iconv.found() - error('Cannot detect iconv API') -endif - curses = not_found -if iconv.found() and not get_option('curses').disabled() - curses_libname_list = ['ncursesw', 'ncurses', 'cursesw', 'pdcurses'] - curses_test = ''' - #include - #include - #include - int main(void) { - wchar_t wch = L'w'; - setlocale(LC_ALL, ""); - resize_term(0, 0); - addwstr(L"wide chars\n"); - addnwstr(&wch, 1); - add_wch(WACS_DEGREE); - return 0; - }''' - foreach curses_libname : curses_libname_list +if have_system and not get_option('curses').disabled() + if not get_option('iconv').disabled() + libiconv = cc.find_library('iconv', + required: false, + static: enable_static) + if cc.links(''' + #include + int main(void) { + iconv_t conv = iconv_open("WCHAR_T", "UCS-2"); + return conv != (iconv_t) -1; + }''', dependencies: [libiconv]) + iconv = declare_dependency(dependencies: [libiconv]) + endif + endif + if get_option('iconv').enabled() and not iconv.found() + error('Cannot detect iconv API') + endif + if iconv.found() + curses_libname_list = ['ncursesw', 'ncurses', 'cursesw', 'pdcurses'] + curses_test = ''' + #include + #include + #include + int main(void) { + wchar_t wch = L'w'; + setlocale(LC_ALL, ""); + resize_term(0, 0); + addwstr(L"wide chars\n"); + addnwstr(&wch, 1); + add_wch(WACS_DEGREE); + return 0; + }''' + foreach curses_libname : curses_libname_list libcurses = dependency(curses_libname, required: false, method: 'pkg-config', @@ -510,13 +510,18 @@ if iconv.found() and not get_option('curses').disabled() break endif endif - endforeach -endif -if get_option('curses').enabled() and not curses.found() - if not iconv.found() - error('Cannot detect iconv API') - else - error('Cannot detect curses API') + endforeach + endif + if not curses.found() + if iconv.found() + if get_option('curses').enabled() + error('Cannot find curses') + endif + elif get_option('curses').enabled() + error('iconv required for curses UI but not available') + else + warning('iconv required for curses UI but not available, disabling') + endif endif endif