kick/meson.build

110 lines
3.9 KiB
Meson
Raw Normal View History

project('tabbed-wlroots', 'c',
version: '0.1.0',
meson_version: '>=1.0',
default_options: ['c_std=c11', 'warning_level=2'])
wlroots_ver = '>=0.19,<0.20'
# wlroots' pkg-config name varies between distributions (wlroots-0.19 on
# Debian/Ubuntu, plain wlroots on Arch/Fedora). Prefer the system copy, and
# fall back to a pinned source build from subprojects/wlroots.wrap when no
# matching system library is found.
wlroots = dependency('wlroots-0.19', version: wlroots_ver, required: false)
if not wlroots.found()
wlroots = dependency('wlroots', version: wlroots_ver, required: false)
endif
if not wlroots.found()
wlroots_subproj = subproject('wlroots',
default_options: ['examples=false', 'werror=false'])
wlroots = wlroots_subproj.get_variable('wlroots')
endif
deps = [
wlroots,
dependency('wayland-server'),
dependency('wayland-client'),
dependency('wayland-egl'),
dependency('xkbcommon'),
dependency('egl'),
dependency('glesv2'),
dependency('freetype2'),
dependency('libpng'),
dependency('librsvg-2.0'),
]
cc = meson.get_compiler('c')
libm = cc.find_library('m', required: false)
if libm.found()
deps += libm
endif
# --- Wayland protocol stubs -------------------------------------------
# The protocol implementation and headers are generated at build time by
# wayland-scanner instead of being committed, so they always match the
# installed wayland-protocols (the previously committed copies were produced
# by wayland-scanner 1.24/1.26 and drifted apart). Outputs land in the build
# directory, which Meson adds to every target's include path automatically;
# that also satisfies the bundled wlroots subproject's wlr_xdg_shell.h and its
# quoted #include "xdg-shell-protocol.h".
wayland_protocols = dependency('wayland-protocols', version: '>=1.17',
fallback: 'wayland-protocols', default_options: ['tests=false'])
wl_protocols_dir = wayland_protocols.get_variable('pkgdatadir')
wayland_scanner_dep = dependency('wayland-scanner', native: true)
wayland_scanner = find_program(
wayland_scanner_dep.get_variable('wayland_scanner'))
# (input xml, output base name). The output base names keep the committed
# suffixes: xdg-decoration is the unstable-v1 protocol but is still named
# plain "xdg-decoration" because the sources #include those exact names.
protocols = {
'xdg-shell': [
wl_protocols_dir / 'stable/xdg-shell/xdg-shell.xml',
'xdg-shell',
],
'xdg-decoration': [
wl_protocols_dir / 'unstable/xdg-decoration/xdg-decoration-unstable-v1.xml',
'xdg-decoration',
],
'wlr-data-control-unstable-v1': [
'wlr-protocols/wlr-data-control-unstable-v1.xml',
'wlr-data-control',
],
}
protocol_sources = []
protocol_headers = []
foreach protocol, p : protocols
xml = p[0]
base = p[1]
protocol_sources += custom_target(protocol + ' protocol code',
input: xml,
output: base + '-protocol.c',
command: [wayland_scanner, 'private-code', '@INPUT@', '@OUTPUT@'])
protocol_headers += custom_target(protocol + ' client header',
input: xml,
output: base + '-client.h',
command: [wayland_scanner, 'client-header', '@INPUT@', '@OUTPUT@'])
if protocol == 'xdg-shell'
protocol_headers += custom_target(protocol + ' server header',
input: xml,
output: base + '-protocol.h',
command: [wayland_scanner, 'server-header', '@INPUT@', '@OUTPUT@'])
endif
endforeach
executable('tabbed-wlroots',
'tabbed-wlroots.c',
protocol_sources,
protocol_headers,
dependencies: deps,
c_args: ['-DWLR_USE_UNSTABLE'])
# wltest needs only the xdg-shell stub (protocol_sources/headers[0]).
executable('wltest',
'tests/wltest.c',
protocol_sources[0],
protocol_headers[0],
dependencies: dependency('wayland-client'))