build: add explicit logind provider option, auto-detect by default

Allow package maintainers to explicitly select a logind provider
by passing -Dlogind=systemd or -Dlogind=elogind. In case both are
available (e.g. for distributions which support both), this makes
it possible to gte deterministic behavior.

By default, auto-detect the logind provider. That way, users which
have systemd or elogind installed get the backend built by default.
This commit is contained in:
Simon Ser 2021-04-07 13:24:19 +02:00 committed by Kenny Levinsen
parent 3ce4c57814
commit 385cc0039d
2 changed files with 14 additions and 10 deletions

View file

@ -109,13 +109,19 @@ endif
logind = disabler() logind = disabler()
logind_provider = '' logind_provider = ''
if not get_option('logind').disabled() if get_option('logind') != 'disabled'
foreach logind_provider : ['elogind', 'systemd'] if get_option('logind') == 'auto'
logind = dependency('lib@0@'.format(logind_provider), required: false) assert(get_option('auto_features').auto(), '-Dlogind must be set to systemd or elogind since auto_features != auto')
if logind.found() foreach logind_provider : ['elogind', 'systemd']
break logind = dependency('lib@0@'.format(logind_provider), required: false)
endif if logind.found()
endforeach break
endif
endforeach
else
logind_provider = get_option('logind')
logind = dependency('lib@0@'.format(logind_provider))
endif
if logind.found() if logind.found()
add_project_arguments('-DLOGIND_ENABLED=1', language: 'c') add_project_arguments('-DLOGIND_ENABLED=1', language: 'c')
@ -125,8 +131,6 @@ if not get_option('logind').disabled()
'common/drm.c', 'common/drm.c',
] ]
private_deps += logind private_deps += logind
elif get_option('logind').enabled()
error('logind backend was enabled but no supported logind provider was found')
endif endif
endif endif

View file

@ -1,4 +1,4 @@
option('logind', type: 'feature', value: 'disabled', description: 'logind support') option('logind', type: 'combo', choices: ['auto', 'disabled', 'elogind', 'systemd'], value: 'auto', description: 'logind support')
option('seatd', type: 'feature', value: 'enabled', description: 'seatd support') option('seatd', type: 'feature', value: 'enabled', description: 'seatd support')
option('builtin', type: 'feature', value: 'disabled', description: 'builtin seatd server') option('builtin', type: 'feature', value: 'disabled', description: 'builtin seatd server')
option('server', type: 'feature', value: 'enabled', description: 'seatd server') option('server', type: 'feature', value: 'enabled', description: 'seatd server')