cage/meson.build
2025-02-16 03:43:51 +09:00

140 lines
3.2 KiB
Meson

project('cage', 'c',
version: '0.2.0',
license: 'MIT',
meson_version: '>=0.58.1',
default_options: [
'c_std=c11',
'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
cc = meson.get_compiler('c')
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
wlroots = dependency('wlroots-0.18', fallback: ['wlroots', 'wlroots'])
wayland_protos = dependency('wayland-protocols', version: '>=1.14')
wayland_server = dependency('wayland-server')
xkbcommon = dependency('xkbcommon')
math = cc.find_library('m')
subdir('protocols')
have_xwayland = wlroots.get_variable(pkgconfig: 'have_xwayland', internal: 'have_xwayland') == 'true'
version = '@0@'.format(meson.project_version())
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)
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)
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',
'layer_shell_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',
'layer_shell_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))