meson.build 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. project('mpi', 'c', 'cpp', default_options: ['b_asneeded=false'])
  2. cc = meson.get_compiler('c')
  3. if build_machine.system() == 'windows' and cc.get_id() != 'msvc'
  4. error('MESON_SKIP_TEST: MPI not available on Windows without MSVC.')
  5. endif
  6. mpic = dependency('mpi', language : 'c', required : false)
  7. if not mpic.found()
  8. error('MESON_SKIP_TEST: MPI not found, skipping.')
  9. endif
  10. exec = executable('exec',
  11. 'main.c',
  12. dependencies : [mpic])
  13. test('MPI C', exec)
  14. if build_machine.system() != 'windows'
  15. # C++ MPI not supported by MS-MPI
  16. mpicpp = dependency('mpi', language : 'cpp')
  17. execpp = executable('execpp',
  18. 'main.cpp',
  19. dependencies : [mpicpp])
  20. test('MPI C++', execpp)
  21. endif
  22. # OpenMPI is broken with Fortran on Ubuntu Artful.
  23. # Remove this once the following bug has been fixed:
  24. #
  25. # https://bugs.launchpad.net/ubuntu/+source/gcc-defaults/+bug/1727474
  26. ubudetector = find_program('is_broken_ubuntu.py')
  27. uburesult = run_command(ubudetector)
  28. if uburesult.returncode() != 0 and add_languages('fortran', required : false)
  29. mpifort = dependency('mpi', language : 'fortran')
  30. # Mixing compilers (msvc/clang with gfortran) does not seem to work on Windows.
  31. if build_machine.system() != 'windows' or cc.get_id() == 'gnu'
  32. exef = executable('exef',
  33. 'main.f90',
  34. dependencies : [mpifort])
  35. test('MPI Fortran', exef)
  36. endif
  37. endif
  38. # Check we can apply a version constraint
  39. if mpic.version() != 'unknown'
  40. dependency('mpi', version: '>=@0@'.format(mpic.version()))
  41. endif