aboutsummaryrefslogtreecommitdiff
path: root/meson.build
diff options
context:
space:
mode:
Diffstat (limited to 'meson.build')
-rw-r--r--meson.build37
1 files changed, 26 insertions, 11 deletions
diff --git a/meson.build b/meson.build
index 780654b00c..9c57ebdfb9 100644
--- a/meson.build
+++ b/meson.build
@@ -180,7 +180,6 @@ endif
##################
qemu_cflags = config_host['QEMU_CFLAGS'].split()
-qemu_cxxflags = config_host['QEMU_CXXFLAGS'].split()
qemu_objcflags = config_host['QEMU_OBJCFLAGS'].split()
qemu_ldflags = config_host['QEMU_LDFLAGS'].split()
@@ -194,7 +193,6 @@ endif
if get_option('gprof')
qemu_cflags += ['-p']
- qemu_cxxflags += ['-p']
qemu_objcflags += ['-p']
qemu_ldflags += ['-p']
endif
@@ -240,8 +238,33 @@ if get_option('fuzzing')
endif
add_global_arguments(qemu_cflags, native: false, language: ['c'])
-add_global_arguments(qemu_cxxflags, native: false, language: ['cpp'])
add_global_arguments(qemu_objcflags, native: false, language: ['objc'])
+
+# Check that the C++ compiler exists and works with the C compiler.
+link_language = 'c'
+linker = cc
+qemu_cxxflags = []
+if add_languages('cpp', required: false, native: false)
+ cxx = meson.get_compiler('cpp')
+ add_global_arguments(['-D__STDC_LIMIT_MACROS', '-D__STDC_CONSTANT_MACROS', '-D__STDC_FORMAT_MACROS'],
+ native: false, language: 'cpp')
+ foreach k: qemu_cflags
+ if k not in ['-Wstrict-prototypes', '-Wmissing-prototypes', '-Wnested-externs',
+ '-Wold-style-declaration', '-Wold-style-definition', '-Wredundant-decls']
+ qemu_cxxflags += [k]
+ endif
+ endforeach
+ add_global_arguments(qemu_cxxflags, native: false, language: 'cpp')
+
+ if cxx.links(files('scripts/main.c'), args: qemu_cflags)
+ link_language = 'cpp'
+ linker = cxx
+ else
+ message('C++ compiler does not work with C compiler')
+ message('Disabling C++-specific optional code')
+ endif
+endif
+
add_global_link_arguments(qemu_ldflags, native: false, language: ['c', 'cpp', 'objc'])
if targetos == 'linux'
@@ -255,14 +278,6 @@ add_project_arguments('-iquote', '.',
'-iquote', meson.current_source_dir() / 'include',
language: ['c', 'cpp', 'objc'])
-link_language = meson.get_external_property('link_language', 'cpp')
-if link_language == 'cpp'
- add_languages('cpp', required: true, native: false)
- cxx = meson.get_compiler('cpp')
- linker = cxx
-else
- linker = cc
-endif
if host_machine.system() == 'darwin'
add_languages('objc', required: false, native: false)
endif