| 1 |
project('fortran_args', 'fortran') |
| 2 |
|
| 3 |
fc = meson.get_compiler('fortran') |
| 4 |
|
| 5 |
if fc.get_id() == 'intel-cl' |
| 6 |
is_arg = '/O2' |
| 7 |
useless = '/DFOO' |
| 8 |
else |
| 9 |
is_arg = '-O2' |
| 10 |
useless = '-DFOO' |
| 11 |
endif |
| 12 |
|
| 13 |
isnt_arg = '-fiambroken' |
| 14 |
|
| 15 |
assert(fc.has_argument(is_arg), 'Arg that should have worked does not work.') |
| 16 |
assert(not fc.has_argument(isnt_arg), 'Arg that should be broken is not.') |
| 17 |
|
| 18 |
assert(fc.get_supported_arguments([is_arg, isnt_arg, useless]) == [is_arg, useless], 'Arg filtering returned different result.') |
| 19 |
|
| 20 |
# Have useless at the end to ensure that the search goes from front to back. |
| 21 |
l1 = fc.first_supported_argument([isnt_arg, is_arg, isnt_arg, useless]) |
| 22 |
l2 = fc.first_supported_argument(isnt_arg, isnt_arg, isnt_arg) |
| 23 |
|
| 24 |
assert(l1.length() == 1, 'First supported returned wrong result.') |
| 25 |
assert(l1.get(0) == is_arg, 'First supported returned wrong argument.') |
| 26 |
assert(l2.length() == 0, 'First supported did not return empty array.') |
| 27 |
|
| 28 |
# --- test with an actual program, here for implicit none |
| 29 |
|
| 30 |
in0 = fc.first_supported_argument('-fimplicit-none', '-Mdclchk', '/warn:declarations', '-warn').get(0, '') |
| 31 |
impnone = { |
| 32 |
'intel-cl': '/warn:declarations', |
| 33 |
'intel': '-warn', |
| 34 |
'gcc': '-fimplicit-none', |
| 35 |
'pgi': '-Mdclchk', |
| 36 |
} |
| 37 |
|
| 38 |
arg = impnone.get(fc.get_id(), '') |
| 39 |
if arg != '' |
| 40 |
assert(in0 == arg, 'implicit none argument ' + arg + ' not matching ' + in0) |
| 41 |
endif |
| 42 |
|
| 43 |
in1 = fc.get_supported_arguments('-fimplicit-none', '/warn:declarations', '/warn:errors', '-Mdclchk') |
| 44 |
if in1.length() > 0 |
| 45 |
assert(not fc.compiles(files('main.f90'), args: in1, name:'will fail implicit none'), 'implicit none should have failed') |
| 46 |
endif |