From e5dfd95dfa185f212a6fd498f70cafa54e2c0831 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Wed, 19 Jul 2023 05:51:59 +0300 Subject: [PATCH 25/25] Meson: Require C++ compiler only when really needed See osdn #47471 Signed-off-by: Marko Lindqvist --- meson.build | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/meson.build b/meson.build index f160b43f4a..2cd858d90e 100644 --- a/meson.build +++ b/meson.build @@ -1,8 +1,17 @@ -project('freeciv', ['c', 'cpp'], meson_version: '>= 0.60.0') +project('freeciv', ['c'], meson_version: '>= 0.60.0') c_compiler = meson.get_compiler('c') -cxx_compiler = meson.get_compiler('cpp') + +if get_option('ruledit') or \ + get_option('clients').contains('qt') or \ + get_option('fcmp').contains('qt') + add_languages('cpp', native: false) + cxx_build = true + cxx_compiler = meson.get_compiler('cpp') +else + cxx_build = false +endif if c_compiler.has_argument('-Wno-nonnull-compare') add_global_arguments('-Wno-nonnull-compare', language : 'c') @@ -213,9 +222,7 @@ if host_system == 'windows' add_global_arguments('-D_WIN32_WINNT=' + min_win_ver, language: ['c', 'cpp']) endif - if get_option('ruledit') or \ - get_option('clients').contains('qt') or \ - get_option('fcmp').contains('qt') + if cxx_build if get_option('debug') # Qt flags have malformed macro definition triggering this error # Also C compiler affected as the macro is on its commandline too @@ -510,7 +517,7 @@ int main(void) { int *var = nullptr; return 0; }''', pub_conf_data.set('FREECIV_HAVE_C23_NULLPTR', 1) endif -if cxx_compiler.compiles(''' +if cxx_build and cxx_compiler.compiles(''' #include int main(void) { int *var = nullptr; return 0; }''', name: 'cxx nullptr', @@ -863,7 +870,7 @@ if crosser pub_conf_data.set('FREECIV_CROSSER', 1) endif -if cxx_compiler.compiles(''' +if cxx_build and cxx_compiler.compiles(''' class me { void top(); }; void me::top() { [=, this]() {}; }; -- 2.40.1