diff --git a/gio/tests/meson.build b/gio/tests/meson.build index c3e4e4cb3..5658eff6f 100644 --- a/gio/tests/meson.build +++ b/gio/tests/meson.build @@ -27,6 +27,8 @@ if cc.has_header('pty.h') endif endif +test_cpp_args = test_c_args + if host_machine.system() == 'windows' common_gio_tests_deps += [iphlpapi_dep, winsock2, cc.find_library ('secur32')] endif @@ -130,8 +132,19 @@ if have_cxx gio_tests += { 'cxx' : { 'source' : ['cxx.cpp'], + 'suite': ['C++'], }, } + + foreach std, arg: cxx_standards + gio_tests += { + 'cxx-@0@'.format(std) : { + 'source' : ['cxx.cpp'], + 'suite' : ['cpp'], + 'cpp_args' : [arg], + }, + } + endforeach endif test_extra_programs = { @@ -853,6 +866,7 @@ foreach test_name, extra_args : gio_tests exe = executable(test_name, [source, extra_sources], c_args : test_c_args + extra_args.get('c_args', []), + cpp_args : test_cpp_args + extra_args.get('cpp_args', []), dependencies : common_gio_tests_deps + extra_args.get('dependencies', []), install_rpath : extra_args.get('install_rpath', ''), install_dir: installed_tests_execdir, diff --git a/glib/tests/meson.build b/glib/tests/meson.build index d74617823..d29afcd03 100644 --- a/glib/tests/meson.build +++ b/glib/tests/meson.build @@ -159,8 +159,19 @@ if have_cxx glib_tests += { 'cxx' : { 'source' : ['cxx.cpp'], + 'suite': ['cpp'], } } + + foreach std, arg: cxx_standards + glib_tests += { + 'cxx-@0@'.format(std) : { + 'source' : ['cxx.cpp'], + 'suite' : ['cpp'], + 'cpp_args' : [arg], + }, + } + endforeach endif if cc.get_id() != 'msvc' @@ -244,6 +255,7 @@ test_env.set('MALLOC_CHECK_', '2') test_deps = [libm, thread_dep, libglib_dep] test_cargs = ['-DG_LOG_DOMAIN="GLib"', '-UG_DISABLE_ASSERT'] +test_cpp_args = test_cargs foreach test_name, extra_args : glib_tests source = extra_args.get('source', test_name + '.c') @@ -264,6 +276,7 @@ foreach test_name, extra_args : glib_tests exe = executable(test_name, source, c_args : test_cargs + extra_args.get('c_args', []), + cpp_args : test_cpp_args + extra_args.get('cpp_args', []), link_args : extra_args.get('link_args', []), dependencies : test_deps + extra_args.get('dependencies', []), install_dir: installed_tests_execdir, diff --git a/gmodule/tests/meson.build b/gmodule/tests/meson.build index cc8125eda..fd2257c1a 100644 --- a/gmodule/tests/meson.build +++ b/gmodule/tests/meson.build @@ -15,8 +15,19 @@ if have_cxx gmodule_tests += { 'cxx' : { 'source' : ['cxx.cpp'], + 'suite' : ['cpp'], } } + + foreach std, arg: cxx_standards + gmodule_tests += { + 'cxx-@0@'.format(std) : { + 'source' : ['cxx.cpp'], + 'suite' : ['cpp'], + 'cpp_args' : [arg], + }, + } + endforeach endif module_suffix = [] @@ -49,6 +60,7 @@ test_env.set('MALLOC_CHECK_', '2') test_deps = [libm, thread_dep, libglib_dep, libgmodule_dep] test_cargs = ['-DG_LOG_DOMAIN="GModule"', '-UG_DISABLE_ASSERT'] +test_cpp_args = test_cargs foreach test_name, extra_args : gmodule_tests source = extra_args.get('source', test_name + '.c') @@ -69,6 +81,7 @@ foreach test_name, extra_args : gmodule_tests exe = executable(test_name, source, c_args : test_cargs + extra_args.get('c_args', []), + cpp_args : test_cpp_args + extra_args.get('cpp_args', []), link_args : extra_args.get('link_args', []), dependencies : test_deps + extra_args.get('dependencies', []), export_dynamic : extra_args.get('export_dynamic', false), diff --git a/gobject/tests/meson.build b/gobject/tests/meson.build index 58cf4ab1f..94eae7527 100644 --- a/gobject/tests/meson.build +++ b/gobject/tests/meson.build @@ -102,8 +102,19 @@ if have_cxx gobject_tests += { 'cxx' : { 'source' : ['cxx.cpp'], + 'suite' : ['cpp'], }, } + + foreach std, arg: cxx_standards + gobject_tests += { + 'cxx-@0@'.format(std) : { + 'source' : ['cxx.cpp'], + 'suite' : ['cpp'], + 'cpp_args' : [arg], + }, + } + endforeach endif if cc.get_id() != 'msvc' @@ -125,6 +136,7 @@ test_env.set('MALLOC_CHECK_', '2') test_deps = [libm, thread_dep, libglib_dep, libgobject_dep] test_cargs = ['-DG_LOG_DOMAIN="GLib-GObject"', '-UG_DISABLE_ASSERT'] +test_cpp_args = test_cargs foreach test_name, extra_args : gobject_tests source = extra_args.get('source', test_name + '.c') @@ -145,6 +157,7 @@ foreach test_name, extra_args : gobject_tests exe = executable(test_name, source, c_args : test_cargs + extra_args.get('c_args', []), + cpp_args : test_cpp_args + extra_args.get('cpp_args', []), dependencies : test_deps + extra_args.get('dependencies', []), install_dir: installed_tests_execdir, install: install, diff --git a/meson.build b/meson.build index f44fa2d4e..56592e491 100644 --- a/meson.build +++ b/meson.build @@ -13,6 +13,14 @@ cc = meson.get_compiler('c') have_cxx = add_languages('cpp', native: false, required: get_option('oss_fuzz').enabled()) if have_cxx cxx = meson.get_compiler('cpp') + cxx_standards = {} + + foreach std : ['98', '03', '11', '14', '17', '20', '2b', 'latest'] + arg = (cxx.get_id() == 'msvc' ? '/std:' : '-std=') + 'c++' + std + if cxx.has_argument(arg) + cxx_standards += { std: arg } + endif + endforeach endif cc_can_run = meson.can_run_host_binaries()