| 1 |
project('openmp', 'c') |
| 2 |
|
| 3 |
cc = meson.get_compiler('c') |
| 4 |
if cc.get_id() == 'gcc' and cc.version().version_compare('<4.2.0') |
| 5 |
error('MESON_SKIP_TEST gcc is too old to support OpenMP.') |
| 6 |
endif |
| 7 |
if cc.get_id() == 'clang' and cc.version().version_compare('<3.7.0') |
| 8 |
error('MESON_SKIP_TEST clang is too old to support OpenMP.') |
| 9 |
endif |
| 10 |
if cc.get_id() == 'msvc' and cc.version().version_compare('<17') |
| 11 |
error('MESON_SKIP_TEST msvc is too old to support OpenMP.') |
| 12 |
endif |
| 13 |
if cc.get_id() == 'clang-cl' and cc.version().version_compare('<10.0.0') |
| 14 |
error('MESON_SKIP_TEST clang-cl is too old to support OpenMP.') |
| 15 |
endif |
| 16 |
if cc.get_id() == 'clang' and host_machine.system() == 'windows' |
| 17 |
error('MESON_SKIP_TEST Windows clang does not support OpenMP.') |
| 18 |
endif |
| 19 |
|
| 20 |
openmp = dependency('openmp') |
| 21 |
env = environment() |
| 22 |
env.set('OMP_NUM_THREADS', '2') |
| 23 |
|
| 24 |
exec = executable('exec', |
| 25 |
'main.c', |
| 26 |
dependencies : [openmp]) |
| 27 |
test('OpenMP C', exec, env : env) |
| 28 |
|
| 29 |
if not(build_machine.system() == 'windows' and cc.get_id() == 'pgi') |
| 30 |
if add_languages('cpp', required : false) |
| 31 |
execpp = executable('execpp', |
| 32 |
'main.cpp', |
| 33 |
dependencies : [openmp]) |
| 34 |
test('OpenMP C++', execpp, env : env) |
| 35 |
endif |
| 36 |
endif |
| 37 |
|
| 38 |
if add_languages('fortran', required : false) |
| 39 |
# Mixing compilers (msvc/clang with gfortran) does not seem to work on Windows. |
| 40 |
if build_machine.system() != 'windows' or cc.get_id() == 'gnu' |
| 41 |
exef = executable('exef', |
| 42 |
'main.f90', |
| 43 |
dependencies : [openmp]) |
| 44 |
test('OpenMP Fortran', exef, env : env) |
| 45 |
|
| 46 |
openmp_f = dependency('openmp', language : 'fortran') |
| 47 |
exe_f = executable('exe_f', |
| 48 |
'main.f90', |
| 49 |
dependencies : [openmp_f]) |
| 50 |
test('OpenMP Fortran-specific', exe_f, env : env) |
| 51 |
endif |
| 52 |
endif |
| 53 |
|
| 54 |
# Check we can apply a version constraint |
| 55 |
dependency('openmp', version: '>=@0@'.format(openmp.version())) |