Installing GSettings schema with meson

How to properly compile and install my app GSettings schemas using meson? There is meson gnome module call compile_schemas(), but it is only work for local consumption, not proper installation.
Just copying schema file and then issuing compile command? :thinking:

Install the schema in the right place:

install_data('com.example.App.gschema.xml',
   install_dir: get_option('datadir') / 'glib-2.0/schemas',
)

and then use the post_install() function on the gnome module:

gnome = import('gnome')
gnome.post_install(glib_compile_schemas: true)

Bonus point for validating the schemas as part of your test suite:


glib_compile_schemas = find_program('glib-compile-schemas', required: false)
if glib_compile_schemas.found()
  test('validate gsettings schemas',
    glib_compile_schemas,
    args: ['--strict', '--dry-run', meson.current_source_dir()],
  )
endif
1 Like