meson.build: Increase version of the compositor
[src/agl-compositor.git] / meson.build
1 project('agl-compositor',
2   'c',
3   version: '0.0.15',
4   default_options: [
5     'warning_level=3',
6     'c_std=gnu99',
7   ],
8   meson_version: '>= 0.47',
9   license: 'MIT/Expat',
10 )
11
12 config_h = configuration_data()
13
14 cc = meson.get_compiler('c')
15 add_project_arguments(
16   cc.get_supported_arguments([
17     '-Wno-unused-parameter',
18     '-Wno-pedantic',
19     '-Wextra',
20     '-Werror'
21   ]),
22   language: 'c'
23 )
24
25 add_project_arguments([
26     '-DPACKAGE_STRING="agl-compositor @0@"'.format(meson.project_version()),
27     '-D_GNU_SOURCE',
28     '-D_ALL_SOURCE',
29   ],
30   language: 'c'
31 )
32
33 optional_libc_funcs = [ 'memfd_create', 'strchrnul' ]
34 foreach func: optional_libc_funcs
35     if cc.has_function(func)
36         add_project_arguments('-DHAVE_@0@=1'.format(func.to_upper()), language: 'c')
37     endif
38 endforeach
39
40 dep_libsystemd = dependency('libsystemd', required: false)
41 dep_scanner = dependency('wayland-scanner', native: true)
42 prog_scanner = find_program(dep_scanner.get_pkgconfig_variable('wayland_scanner'))
43 dep_wp = dependency('wayland-protocols', version: '>= 1.18')
44 dir_wp_base = dep_wp.get_pkgconfig_variable('pkgdatadir')
45
46 agl_shell_xml = files('protocol/agl-shell.xml')
47 xdg_shell_xml = join_paths(dir_wp_base, 'stable', 'xdg-shell', 'xdg-shell.xml')
48
49 protocols = [
50   { 'name': 'agl-shell', 'source': 'internal' },
51   { 'name': 'xdg-shell', 'source': 'wp-stable' },
52 ]
53
54 foreach proto: protocols
55     proto_name = proto['name']
56     if proto['source'] == 'internal'
57         base_file = proto_name
58         xml_path = join_paths('protocol', '@0@.xml'.format(base_file))
59     elif proto['source'] == 'wp-stable'
60         base_file = proto_name
61         xml_path = join_paths(dir_wp_base, 'stable', proto_name, '@0@.xml'.format(base_file))
62     else
63         base_file = '@0@-unstable-@1@'.format(proto_name, proto['version'])
64         xml_path = join_paths(dir_wp_base, 'unstable', proto_name, '@0@.xml'.format(base_file))
65     endif
66
67     foreach output_type: [ 'client-header', 'server-header', 'private-code' ]
68         if output_type == 'client-header'
69             output_file = '@0@-client-protocol.h'.format(base_file)
70         elif output_type == 'server-header'
71             output_file = '@0@-server-protocol.h'.format(base_file)
72         else
73             output_file = '@0@-protocol.c'.format(base_file)
74             if dep_scanner.version().version_compare('< 1.14.91')
75                 output_type = 'code'
76             endif
77         endif
78
79         var_name = output_file.underscorify()
80         target = custom_target(
81             '@0@ @1@'.format(base_file, output_type),
82             command: [ prog_scanner, output_type, '@INPUT@', '@OUTPUT@' ],
83             input: xml_path,
84             output: output_file,
85         )
86
87         set_variable(var_name, target)
88     endforeach
89 endforeach
90
91 # libweston-6 pkg-config file already has 'libweston-6' as prefix but
92 # agl-compositor uses 'libweston-6' also. This makes use of the prefix
93 # path as to allow building and installing the compositor locally
94 prefix_path = get_option('prefix')
95 message('prefix_path ' + prefix_path)
96 if not prefix_path.contains('/usr')
97   additional_include_dir = include_directories(prefix_path + '/' + 'include')
98   local_dep = declare_dependency(include_directories: additional_include_dir)
99 else
100   local_dep = []
101 endif
102
103 libweston_dep = dependency('libweston-7')
104
105 deps_libweston = [
106   dependency('wayland-server'),
107   libweston_dep,
108   dependency('libweston-desktop-7'),
109   local_dep,
110 ]
111
112 srcs_agl_compositor = [
113         'src/main.c',
114         'src/desktop.c',
115         'src/layout.c',
116         'src/shell.c',
117         'shared/option-parser.c',
118         'shared/os-compatibility.c',
119         agl_shell_server_protocol_h,
120         agl_shell_protocol_c,
121         xdg_shell_protocol_c,
122 ]
123
124 # From meson documentation:
125 # In order to look for headers in a specific directory you can use args :
126 # '-I/extra/include/dir, but this should only be used in exceptional cases for
127 # includes that can't be detected via pkg-config and passed via dependencies.
128 if libweston_dep.found()
129   if not prefix_path.contains('/usr')
130     dir_path_x11_backend = join_paths(prefix_path, 'include', 'libweston-7', 'libweston', 'backend-x11.h')
131   else
132     dir_path_x11_backend = join_paths('libweston-7', 'libweston', 'backend-x11.h')
133   endif
134
135   # do the test
136   if cc.has_header(dir_path_x11_backend)
137     config_h.set('HAVE_BACKEND_X11', 1)
138   endif
139 endif
140
141 if dep_libsystemd.found()
142   config_h.set('HAVE_SYSTEMD', 1)
143
144   srcs_agl_compositor += 'src/systemd-notify.c'
145   deps_libweston += dep_libsystemd
146
147   message('Found systemd, enabling notify support')
148 endif
149
150 configure_file(output: 'config.h', configuration: config_h)
151
152 exe_agl_compositor = executable(
153         'agl-compositor',
154         srcs_agl_compositor,
155         dependencies: deps_libweston,
156         install: true
157 )