From faa6a2311cd5d2ee279454e4b51e907b4ed60046 Mon Sep 17 00:00:00 2001 From: Qball Date: Wed, 28 May 2025 23:14:01 +0200 Subject: [PATCH] [Build] Use auto-option for enabling/disabling wayland/xcb --- meson.build | 33 +++++++++++++++++++++++++-------- meson_options.txt | 4 ++-- 2 files changed, 27 insertions(+), 10 deletions(-) diff --git a/meson.build b/meson.build index 86dfd896..72550b02 100644 --- a/meson.build +++ b/meson.build @@ -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) diff --git a/meson_options.txt b/meson_options.txt index 4e911a2d..7647da32 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -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')