cage/meson.build

160 lines
3.7 KiB
Meson
Raw Normal View History

project('cage', 'c',
2025-10-01 17:46:45 +02:00
version: '0.2.1',
license: 'MIT',
2021-12-18 12:55:08 +01:00
meson_version: '>=0.58.1',
default_options: [
'c_std=c11',
2021-12-18 12:55:08 +01:00
'warning_level=2',
'werror=true',
],
)
add_project_arguments(
[
'-DWLR_USE_UNSTABLE',
'-Wundef',
'-Wno-unused-parameter',
],
language: 'c',
)
if get_option('buildtype').startswith('debug')
add_project_arguments('-DDEBUG', language : 'c')
endif
2019-01-20 13:42:36 +01:00
cc = meson.get_compiler('c')
2019-04-20 19:32:00 +02:00
is_freebsd = host_machine.system().startswith('freebsd')
if is_freebsd
add_project_arguments(
[
'-Wno-format-extra-args',
'-Wno-gnu-zero-variadic-macro-arguments',
],
language: 'c'
)
endif
2025-04-10 17:50:15 +02:00
wlroots = dependency('wlroots-0.19', fallback: ['wlroots', 'wlroots'])
wayland_protos = dependency('wayland-protocols', version: '>=1.14')
wayland_server = dependency('wayland-server')
xkbcommon = dependency('xkbcommon')
2021-12-22 08:14:39 +02:00
math = cc.find_library('m')
wl_protocol_dir = wayland_protos.get_variable('pkgdatadir')
wayland_scanner = find_program('wayland-scanner')
wayland_scanner_server = generator(
wayland_scanner,
output: '@BASENAME@-protocol.h',
arguments: ['server-header', '@INPUT@', '@OUTPUT@'],
)
server_protocols = [
[wl_protocol_dir, 'stable/xdg-shell/xdg-shell.xml'],
]
server_protos_headers = []
foreach p : server_protocols
xml = join_paths(p)
server_protos_headers += wayland_scanner_server.process(xml)
endforeach
server_protos = declare_dependency(
sources: server_protos_headers,
)
have_xwayland = wlroots.get_variable(pkgconfig: 'have_xwayland', internal: 'have_xwayland') == 'true'
version = '@0@'.format(meson.project_version())
2020-01-26 17:49:26 +01:00
git = find_program('git', native: true, required: false)
if git.found()
git_commit = run_command([git, 'rev-parse', '--short', 'HEAD'], check: false)
git_branch = run_command([git, 'rev-parse', '--abbrev-ref', 'HEAD'], check: false)
2020-01-26 17:49:26 +01:00
if git_commit.returncode() == 0 and git_branch.returncode() == 0
version = '@0@-@1@ (branch \'@2@\')'.format(
meson.project_version(),
git_commit.stdout().strip(),
git_branch.stdout().strip(),
)
endif
endif
conf_data = configuration_data()
conf_data.set10('CAGE_HAS_XWAYLAND', have_xwayland)
2020-01-26 17:49:26 +01:00
conf_data.set_quoted('CAGE_VERSION', version)
scdoc = dependency('scdoc', version: '>=1.9.2', native: true, required: get_option('man-pages'))
if scdoc.found()
scdoc_prog = find_program(scdoc.get_variable('scdoc'), native: true)
sh = find_program('sh', native: true)
mandir = get_option('mandir')
man_files = [
'cage.1.scd'
]
foreach filename : man_files
topic = filename.split('.')[-3].split('/')[-1]
section = filename.split('.')[-2]
output = '@0@.@1@'.format(topic, section)
custom_target(
output,
input: filename,
output: output,
command: [
sh, '-c', '@0@ < @INPUT@ > @1@'.format(scdoc_prog.full_path(), output)
],
install: true,
install_dir: '@0@/man@1@'.format(mandir, section)
)
endforeach
endif
cage_sources = [
'cage.c',
'idle_inhibit_v1.c',
'output.c',
'seat.c',
'view.c',
'xdg_shell.c',
]
cage_headers = [
configure_file(input: 'config.h.in',
output: 'config.h',
configuration: conf_data),
'idle_inhibit_v1.h',
'output.h',
'seat.h',
'server.h',
'view.h',
'xdg_shell.h',
]
if conf_data.get('CAGE_HAS_XWAYLAND', 0) == 1
cage_sources += 'xwayland.c'
cage_headers += 'xwayland.h'
endif
executable(
meson.project_name(),
cage_sources + cage_headers,
dependencies: [
server_protos,
wayland_server,
wlroots,
xkbcommon,
math,
],
install: true,
)
summary = [
'',
'Cage @0@'.format(version),
'',
' xwayland: @0@'.format(have_xwayland),
''
]
message('\n'.join(summary))