src/: Add basic support for app switching
[src/agl-compositor.git] / meson.build
1 project('agl-compositor',
2   'c',
3   version: '0.0.13',
4   default_options: [
5     'warning_level=3',
6     'c_std=gnu99',
7   ],
8   meson_version: '>= 0.47',
9   license: 'MIT/Expat',
10 )
11
12 cc = meson.get_compiler('c')
13 add_project_arguments(
14   cc.get_supported_arguments([
15     '-Wno-unused-parameter',
16     '-Wno-pedantic',
17   ]),
18   language: 'c'
19 )
20
21 add_project_arguments([
22     '-DPACKAGE_STRING="agl-compositor @0@"'.format(meson.project_version()),
23     '-D_GNU_SOURCE',
24     '-D_ALL_SOURCE',
25   ],
26   language: 'c'
27 )
28
29 optional_libc_funcs = [ 'memfd_create', 'strchrnul' ]
30 foreach func: optional_libc_funcs
31     if cc.has_function(func)
32         add_project_arguments('-DHAVE_@0@=1'.format(func.to_upper()), language: 'c')
33     endif
34 endforeach
35
36 dep_scanner = dependency('wayland-scanner', native: true)
37 prog_scanner = find_program(dep_scanner.get_pkgconfig_variable('wayland_scanner'))
38 dep_wp = dependency('wayland-protocols', version: '>= 1.12')
39 dir_wp_base = dep_wp.get_pkgconfig_variable('pkgdatadir')
40
41 agl_shell_xml = files('protocol/agl-shell.xml')
42 xdg_shell_xml = join_paths(dir_wp_base, 'stable', 'xdg-shell', 'xdg-shell.xml')
43
44 protocols = [
45   { 'name': 'agl-shell', 'source': 'internal' },
46   { 'name': 'xdg-shell', 'source': 'wp-stable' },
47 ]
48
49 foreach proto: protocols
50     proto_name = proto['name']
51     if proto['source'] == 'internal'
52         base_file = proto_name
53         xml_path = join_paths('protocol', '@0@.xml'.format(base_file))
54     elif proto['source'] == 'wp-stable'
55         base_file = proto_name
56         xml_path = join_paths(dir_wp_base, 'stable', proto_name, '@0@.xml'.format(base_file))
57     else
58         base_file = '@0@-unstable-@1@'.format(proto_name, proto['version'])
59         xml_path = join_paths(dir_wp_base, 'unstable', proto_name, '@0@.xml'.format(base_file))
60     endif
61
62     foreach output_type: [ 'client-header', 'server-header', 'private-code' ]
63         if output_type == 'client-header'
64             output_file = '@0@-client-protocol.h'.format(base_file)
65         elif output_type == 'server-header'
66             output_file = '@0@-server-protocol.h'.format(base_file)
67         else
68             output_file = '@0@-protocol.c'.format(base_file)
69             if dep_scanner.version().version_compare('< 1.14.91')
70                 output_type = 'code'
71             endif
72         endif
73
74         var_name = output_file.underscorify()
75         target = custom_target(
76             '@0@ @1@'.format(base_file, output_type),
77             command: [ prog_scanner, output_type, '@INPUT@', '@OUTPUT@' ],
78             input: xml_path,
79             output: output_file,
80         )
81
82         set_variable(var_name, target)
83     endforeach
84 endforeach
85
86 deps_libweston = [
87   dependency('wayland-server'),
88   dependency('libweston-6'),
89   dependency('libweston-desktop-6'),
90 ]
91
92 srcs_agl_compositor = [
93         'src/main.c',
94         'src/desktop.c',
95         'src/layout.c',
96         'src/shell.c',
97         'shared/option-parser.c',
98         'shared/os-compatibility.c',
99         agl_shell_server_protocol_h,
100         agl_shell_protocol_c,
101         xdg_shell_protocol_c,
102 ]
103
104 exe_agl_compositor = executable(
105         'agl-compositor',
106         srcs_agl_compositor,
107         dependencies: deps_libweston,
108         install: true
109 )