meson.build 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. project('invercargill-sql', ['vala', 'c'], version: '0.1')
  2. # Required dependencies
  3. glib_dep = dependency('glib-2.0')
  4. gobject_dep = dependency('gobject-2.0')
  5. invercargill_dep = dependency('invercargill-1')
  6. sqlite_dep = dependency('sqlite3')
  7. libpq_dep = dependency('libpq')
  8. # libpq: Vala's libpq.vapi emits "#include <postgresql/libpq-fe.h>" in the
  9. # generated C, but distros disagree on the header location (Debian keeps
  10. # them under /usr/include/postgresql, Fedora-style layouts install them
  11. # flat in /usr/include). Probe with the C compiler and, when the flat
  12. # layout is found, create a compat include dir with a postgresql/ symlink
  13. # tree in the build directory.
  14. cc = meson.get_compiler('c')
  15. libpq_compat_args = []
  16. if not cc.has_header('postgresql/libpq-fe.h', dependencies: libpq_dep)
  17. if not cc.has_header('libpq-fe.h', dependencies: libpq_dep)
  18. error('libpq headers not found; install libpq-devel/postgresql-devel')
  19. endif
  20. pg_includedir = run_command(
  21. find_program('pkg-config'), '--variable=includedir', 'libpq',
  22. check: true,
  23. ).stdout().strip()
  24. pg_compat = meson.current_build_dir() / 'pg-compat/postgresql'
  25. run_command('mkdir', '-p', pg_compat, check: true)
  26. foreach h : ['libpq-fe.h', 'libpq-events.h']
  27. run_command('ln', '-sfn', pg_includedir / h, pg_compat / h, check: true)
  28. endforeach
  29. run_command('ln', '-sfn', pg_includedir / 'libpq', pg_compat / 'libpq', check: true)
  30. libpq_compat_args = ['-I' + meson.current_build_dir() / 'pg-compat']
  31. endif
  32. # Subdirectories
  33. subdir('src')
  34. subdir('examples')