meson.build 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. project('openmp', 'c', 'cpp')
  2. cc = meson.get_compiler('c')
  3. if cc.get_id() == 'gcc' and cc.version().version_compare('<4.2.0')
  4. error('MESON_SKIP_TEST gcc is too old to support OpenMP.')
  5. endif
  6. if cc.get_id() == 'clang' and cc.version().version_compare('<3.7.0')
  7. error('MESON_SKIP_TEST clang is too old to support OpenMP.')
  8. endif
  9. if cc.get_id() == 'msvc' and cc.version().version_compare('<17')
  10. error('MESON_SKIP_TEST msvc is too old to support OpenMP.')
  11. endif
  12. if host_machine.system() == 'darwin'
  13. error('MESON_SKIP_TEST macOS does not support OpenMP.')
  14. endif
  15. openmp = dependency('openmp')
  16. exec = executable('exec',
  17. 'main.c',
  18. dependencies : [openmp])
  19. execpp = executable('execpp',
  20. 'main.cpp',
  21. dependencies : [openmp])
  22. env = environment()
  23. env.set('OMP_NUM_THREADS', '2')
  24. test('OpenMP C', exec, env : env)
  25. test('OpenMP C++', execpp, env : env)
  26. if add_languages('fortran', required : false)
  27. exef = executable('exef',
  28. 'main.f90',
  29. dependencies : [openmp])
  30. test('OpenMP Fortran', execpp, env : env)
  31. endif