build: introduce sd-bus-provider option

Based on https://github.com/emersion/mako/commit/67f2ed1862a9
This commit is contained in:
Jan Beich 2020-12-21 11:23:14 +00:00 committed by Simon Ser
parent 727f13f34d
commit 7b7d927cae
3 changed files with 21 additions and 9 deletions

View file

@ -2,9 +2,9 @@
#define XDPW_H
#include <wayland-client.h>
#ifdef HAVE_SYSTEMD
#ifdef HAVE_LIBSYSTEMD
#include <systemd/sd-bus.h>
#elif HAVE_ELOGIND
#elif HAVE_LIBELOGIND
#include <elogind/sd-bus.h>
#endif

View file

@ -3,7 +3,7 @@ project(
'c',
version: '0.1.0',
license: 'MIT',
meson_version: '>=0.47.0',
meson_version: '>=0.50.0',
default_options: [
'c_std=c11',
'warning_level=2',
@ -27,13 +27,24 @@ pipewire = dependency('libpipewire-0.3', version: '>= 0.3.2')
wayland_client = dependency('wayland-client')
wayland_protos = dependency('wayland-protocols', version: '>=1.14')
logind = dependency('libsystemd', required: false)
if logind.found()
add_project_arguments('-DHAVE_SYSTEMD=1', language: 'c')
if get_option('sd-bus-provider') == 'auto'
assert(get_option('auto_features').auto(), 'sd-bus-provider must not be set to auto since auto_features != auto')
sdbus = dependency('libsystemd',
required: false,
not_found_message: 'libsystemd not found, trying libelogind',
)
if not sdbus.found()
sdbus = dependency('libelogind',
required: false,
)
endif
if not sdbus.found()
error('Neither libsystemd, nor libelogind was found')
endif
else
logind = dependency('libelogind')
add_project_arguments('-DHAVE_ELOGIND=1', language: 'c')
sdbus = dependency(get_option('sd-bus-provider'))
endif
add_project_arguments('-DHAVE_' + sdbus.name().to_upper() + '=1', language: 'c')
subdir('protocols')
@ -53,7 +64,7 @@ executable(
dependencies: [
wayland_client,
wlr_protos,
logind,
sdbus,
pipewire,
rt,
],

View file

@ -1 +1,2 @@
option('sd-bus-provider', type: 'combo', choices: ['auto', 'libsystemd', 'libelogind'], value: 'auto', description: 'Provider of the sd-bus library')
option('systemd', type: 'feature', value: 'auto', description: 'Install systemd user service unit')