Skip to content

Commit

Permalink
Meson: Require C++ compiler only when really needed
Browse files Browse the repository at this point in the history
See osdn #47471

Signed-off-by: Marko Lindqvist <cazfi74@gmail.com>
  • Loading branch information
cazfi committed Jul 19, 2023
1 parent 5367ee3 commit 3c8eb26
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions meson.build
Original file line number Diff line number Diff line change
@@ -1,13 +1,22 @@

project('freeciv', ['c', 'cpp'], meson_version: '>= 0.57.0')
project('freeciv', ['c'], meson_version: '>= 0.57.0')

if not get_option('ack_experimental')
error('Autotools are still the only fully supported way to build freeciv.\nSet configure option "ack_experimental" to true if you really want to do experimental meson build.\n' +
'Most scripts that do freeciv build with meson allow you to pass configure options\nvia environment variable EXTRA_CONFIG.')
endif

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')
Expand Down Expand Up @@ -143,9 +152,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
Expand Down Expand Up @@ -673,7 +680,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]() {}; };
Expand Down

0 comments on commit 3c8eb26

Please sign in to comment.