main meson.build
 1project('swc', 'c',
 2  version: '0.0',
 3  meson_version: '>=1.7.99',
 4  license: 'MIT',
 5  default_options: [
 6    'c_std=c11',
 7    'warning_level=1',
 8    'default_library=both',
 9  ],
10)
11
12cc = meson.get_compiler('c')
13os = host_machine.system()
14pkg = import('pkgconfig')
15wl = import('wayland')
16
17add_project_arguments(cc.get_supported_arguments([
18  '-fvisibility=hidden',
19
20  '-Werror=implicit-function-declaration',
21  '-Werror=implicit-int',
22  '-Werror=pointer-sign',
23  '-Werror=pointer-arith',
24  '-Wno-missing-braces',
25]) + [
26  '-D_GNU_SOURCE', # Required for mkostemp
27  get_option('buildtype').startswith('debug') ? '-DENABLE_DEBUG=1' : [],
28], language: 'c')
29
30requires = [
31  dependency('wayland-server', version: '>=1.6.0'),
32]
33requires_private = [
34  dependency('libdrm'),
35  dependency('pixman-1'),
36  dependency('wayland-protocols'),
37  dependency('wld'),
38  dependency('xkbcommon'),
39]
40
41xwayland = dependency('xwayland', required: get_option('xwayland'))
42xwayland_deps = [
43  'xcb',
44  'xcb-composite',
45  'xcb-ewmh',
46  'xcb-icccm',
47]
48if xwayland.found()
49  add_project_arguments('-DENABLE_XWAYLAND', language: 'c')
50  requires_private += xwayland
51  foreach dep : xwayland_deps
52    requires_private += dependency(dep, required: xwayland.found())
53	endforeach
54endif
55
56input_backend = get_option('input')
57libinput = dependency('libinput', version: '>=0.4', required: input_backend == 'libinput')
58
59if input_backend == 'auto'
60  if os == 'linux'
61    if not libinput.found()
62      error('libinput is required for the Linux input backend')
63    endif
64    input_backend = 'libinput'
65  elif os == 'netbsd' or os == 'openbsd'
66    input_backend = 'wscons'
67  else
68    error('Failed to determine input backend for ' + os)
69  endif
70endif  
71
72if input_backend == 'libinput'
73  udev = dependency('libudev', required: get_option('udev'))
74  if udev.found()
75    add_project_arguments('-DENABLE_LIBUDEV', language: 'c')
76  endif
77  requires_private += [libinput, udev]
78endif
79
80subdir('protocol')
81subdir('cursor')
82subdir('launch')
83subdir('libswc')
84
85if get_option('extra')
86  subdir('extra')
87endif
88
89if get_option('example')
90  subdir('example')
91endif
92
93summary({
94  'Xwayland support': xwayland.found(),
95  'Input backend': input_backend,
96}, bool_yn: true)