[Build] Use auto-option for enabling/disabling wayland/xcb

This commit is contained in:
Qball
2025-05-28 23:14:01 +02:00
parent 88dc74c028
commit faa6a2311c
2 changed files with 27 additions and 10 deletions

View File

@@ -66,15 +66,26 @@ deps = [
dep_lm,
]
xcb_enabled = get_option('xcb').enabled()
wayland_enabled = get_option('wayland').enabled()
assert(xcb_enabled or wayland_enabled,
'At least one of these options must be enabled: wayland, xcb')
libgwater = subproject('libgwater')
xcb = dependency('xcb', required: xcb_enabled )
##
# Check if atleast xcb or wayland is allowed in build configuration.
# No point in having no backend.
##
xcb_allowed= get_option('xcb').allowed()
wayland_allowed = get_option('wayland').allowed()
assert(xcb_allowed or wayland_allowed,
'At least one of these options must be allowed: wayland, xcb')
##
# Check what two options should be available.
##
xcb = dependency('xcb', required: get_option('xcb').enabled())
wayland_protocols = dependency('wayland-protocols', version: '>= 1.17', required: get_option('wayland').enabled())
xcb_enabled = xcb.found()
wayland_enabled = wayland_protocols.found()
# XCB stuff
if xcb_enabled
deps += [
@@ -94,7 +105,6 @@ if xcb_enabled
]
endif
wayland_protocols = dependency('wayland-protocols', version: '>= 1.17', required: wayland_enabled)
if wayland_enabled
deps += [
@@ -105,6 +115,13 @@ if wayland_enabled
]
endif
##
# If both in auto mode, but none found. Check again if atleast one exists.
##
assert(xcb_enabled or wayland_enabled,
'At least one of these options must be found: wayland, xcb')
header_conf = configuration_data()
if get_option('imdkit')
imdkit_new = dependency('xcb-imdkit', version: '>= 1.0.3', required: false)

View File

@@ -2,5 +2,5 @@ option('drun', type: 'boolean', value: true, description: 'Desktop file mode')
option('window', type: 'boolean', value: true, description: 'Window switcher mode')
option('check', type: 'feature', description: 'Build and run libcheck-based tests')
option('imdkit', type: 'boolean', value: true, description: 'IMDKit support')
option('wayland', type: 'feature', value: 'enabled', description: 'Build with wayland support')
option('xcb', type: 'feature', value: 'enabled', description: 'Build with X11/xcb support')
option('wayland', type: 'feature', value: 'auto', description: 'Build with wayland support')
option('xcb', type: 'feature', value: 'auto', description: 'Build with X11/xcb support')