meson.build 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. project('pkgconfig-gen', 'c')
  2. # First check we have pkg-config >= 0.29
  3. pkgconfig = find_program('pkg-config', required: false)
  4. if not pkgconfig.found()
  5. error('MESON_SKIP_TEST: pkg-config not found')
  6. endif
  7. v = run_command(pkgconfig, '--version').stdout().strip()
  8. if v.version_compare('<0.29')
  9. error('MESON_SKIP_TEST: pkg-config version \'' + v + '\' too old')
  10. endif
  11. pkgg = import('pkgconfig')
  12. lib = shared_library('simple', 'simple.c')
  13. libver = '1.0'
  14. h = install_headers('simple.h')
  15. pkgg.generate(
  16. libraries : [lib, '-lz'],
  17. subdirs : '.',
  18. version : libver,
  19. name : 'libsimple',
  20. filebase : 'simple',
  21. description : 'A simple demo library.',
  22. requires : 'glib-2.0', # Not really, but only here to test that this works.
  23. requires_private : ['gio-2.0', 'gobject-2.0'],
  24. libraries_private : [lib, '-lz'],
  25. )
  26. test('pkgconfig-validation', pkgconfig,
  27. args: ['--validate', 'simple'],
  28. env: [ 'PKG_CONFIG_PATH=' + meson.current_build_dir() + '/meson-private' ])
  29. # Test that name_prefix='' and name='libfoo' results in '-lfoo'
  30. lib2 = shared_library('libfoo', 'simple.c',
  31. name_prefix : '',
  32. version : libver)
  33. pkgg.generate(
  34. libraries : lib2,
  35. name : 'libfoo',
  36. version : libver,
  37. description : 'A foo library.',
  38. variables : ['foo=bar', 'datadir=${prefix}/data']
  39. )
  40. pkgg.generate(
  41. name : 'libhello',
  42. description : 'A minimalistic pkgconfig file.',
  43. version : libver,
  44. )