meson.build 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. project('llvmtest', ['c', 'cpp'], default_options : ['c_std=c99'])
  2. d = dependency('llvm', required : false)
  3. if not d.found()
  4. d = dependency('llvm', required : false, static : true)
  5. if not d.found()
  6. error('MESON_SKIP_TEST llvm not found.')
  7. else
  8. static = true
  9. endif
  10. else
  11. static = false
  12. endif
  13. d = dependency('llvm', modules : 'not-found', required : false, static : static)
  14. assert(d.found() == false, 'not-found llvm module found')
  15. d = dependency('llvm', version : '<0.1', required : false, static : static)
  16. assert(d.found() == false, 'ancient llvm module found')
  17. d = dependency('llvm', optional_modules : 'not-found', required : false, static : static)
  18. assert(d.found() == true, 'optional module stopped llvm from being found.')
  19. # Check we can apply a version constraint
  20. d = dependency('llvm', version : ['< 500', '>=@0@'.format(d.version())], required: false, static : static)
  21. assert(d.found() == true, 'Cannot set version constraints')
  22. dep_tinfo = dependency('tinfo', required : false)
  23. if not dep_tinfo.found()
  24. cpp = meson.get_compiler('cpp')
  25. dep_tinfo = cpp.find_library('tinfo', required: false)
  26. endif
  27. foreach static : [true, false]
  28. llvm_dep = dependency(
  29. 'llvm',
  30. modules : ['bitwriter', 'asmprinter', 'executionengine', 'target',
  31. 'mcjit', 'nativecodegen'],
  32. required : false,
  33. static : static,
  34. )
  35. if llvm_dep.found()
  36. name = static ? 'static' : 'dynamic'
  37. executable(
  38. 'sum-@0@'.format(name),
  39. 'sum.c',
  40. dependencies : [
  41. llvm_dep, dep_tinfo,
  42. # zlib will be statically linked on windows
  43. dependency('zlib', required : host_machine.system() != 'windows'),
  44. meson.get_compiler('c').find_library('dl', required : false),
  45. ]
  46. )
  47. endif
  48. endforeach