build: Use override_options for C standard selection

Do not try to inject the C standard into `c_args`: Meson already
generates a compiler command line with the appropriate C standard, and
adding another one into it at a random position is either potentially
undefined behaviour, or it's going to break the build because the
compiler does not accept more than one switch.

Meson has an `override_options` argument for the executable() object,
and we are already using it in places.
This commit is contained in:
Emmanuele Bassi 2024-05-16 14:27:42 +01:00
parent 1fb47422e9
commit 5e8e4424c4

View File

@ -372,10 +372,12 @@ foreach test_name, extra_args : glib_tests
'@0@-c-@1@'.format(test_name, std) : extra_args + {
'source' : extra_args.get('source', test_name + '.c'),
'suite' : ['cc'] + extra_args.get('suite', []),
'c_args' : [
c_standards.get(std),
'-D_G_EXPECTED_C_STANDARD="@0@"'.format(std)
] + extra_args.get('c_args', []),
'override_options' : extra_args.get('override_options', []) + [
'c_std=c@0@'.format(std),
],
'c_args' : extra_args.get('c_args', []) + [
'-D_G_EXPECTED_C_STANDARD="@0@"'.format(std),
],
}
}
endif