meson.build 1.3 KB

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