Wayland compositor (wlroots)
git clone https://git.lucas.co/cce-compositor.git
scenefx/meson.build (4.3K)
1 project(
2 'scenefx',
3 'c',
4 version: '0.5.0',
5 license: 'MIT',
6 meson_version: '>=1.3',
7 default_options: [
8 'c_std=' + (meson.version().version_compare('>=1.4.0') ? 'c23,c11' : 'c11'),
9 'warning_level=2',
10 'werror=true',
11 'wrap_mode=nodownload',
12 ],
13 )
14
15 version = meson.project_version().split('-')[0]
16 version_major = version.split('.')[0]
17 version_minor = version.split('.')[1]
18 versioned_name = '@0@-@1@.@2@'.format(meson.project_name(), version_major, version_minor)
19
20 little_endian = target_machine.endian() == 'little'
21 big_endian = target_machine.endian() == 'big'
22
23 add_project_arguments([
24 '-D_POSIX_C_SOURCE=200809L',
25 '-DWLR_USE_UNSTABLE',
26 '-DWLR_PRIVATE=',
27 '-DWLR_LITTLE_ENDIAN=@0@'.format(little_endian.to_int()),
28 '-DWLR_BIG_ENDIAN=@0@'.format(big_endian.to_int()),
29 ], language: 'c')
30
31 cc = meson.get_compiler('c')
32
33 add_project_arguments(cc.get_supported_arguments([
34 '-Wundef',
35 '-Wlogical-op',
36 '-Wmissing-include-dirs',
37 '-Wold-style-definition',
38 '-Wpointer-arith',
39 '-Winit-self',
40 '-Wstrict-prototypes',
41 '-Wimplicit-fallthrough=2',
42 '-Wendif-labels',
43 '-Wstrict-aliasing=2',
44 '-Woverflow',
45 '-Wmissing-prototypes',
46 '-Walloca',
47
48 '-Wno-missing-braces',
49 '-Wno-missing-field-initializers',
50 '-Wno-unused-parameter',
51 ]), language: 'c')
52
53 fs = import('fs')
54
55 # Strip relative path prefixes from the code if possible, otherwise hide them.
56 relative_dir = fs.relative_to(meson.current_source_dir(), meson.global_build_root()) + '/'
57 if cc.has_argument('-fmacro-prefix-map=/prefix/to/hide=')
58 add_project_arguments(
59 '-fmacro-prefix-map=@0@='.format(relative_dir),
60 language: 'c',
61 )
62 else
63 add_project_arguments(
64 '-D_WLR_REL_SRC_DIR="@0@"'.format(relative_dir),
65 language: 'c',
66 )
67 endif
68
69 features = {
70 'gles2-renderer': true,
71 'color-management': false,
72 }
73 internal_features = {
74 'egl': false,
75 'tracy': false,
76 }
77
78 wayland_kwargs = {
79 'version': '>=1.24.0',
80 'fallback': 'wayland',
81 'default_options': [
82 'tests=false',
83 'documentation=false',
84 ],
85 }
86 wayland_server = dependency('wayland-server',
87 kwargs: wayland_kwargs,
88 )
89
90 wlroots_options = [ 'examples=false' ]
91 wlroots_version = ['>=0.20.0', '<0.21.0']
92 wlroots = dependency('wlroots-0.20',
93 version: wlroots_version,
94 default_options: wlroots_options,
95 required: false,
96 )
97 if not wlroots.found()
98 wlroots_proj = subproject(
99 'wlroots',
100 default_options: wlroots_options,
101 version: wlroots_version,
102 )
103 wlroots = wlroots_proj.get_variable('wlroots')
104 endif
105
106
107 drm = dependency('libdrm',
108 version: '>=2.4.129',
109 fallback: 'libdrm',
110 default_options: [
111 'auto_features=disabled',
112 'tests=false',
113 ],
114 )
115 xkbcommon = dependency('xkbcommon',
116 version: '>=1.8.0',
117 fallback: 'libxkbcommon',
118 default_options: [
119 'enable-tools=false',
120 'enable-x11=false',
121 'enable-docs=false',
122 'enable-xkbregistry=false',
123 ],
124 )
125 pixman = dependency('pixman-1',
126 version: '>=0.43.0',
127 fallback: 'pixman',
128 default_options: ['werror=false'],
129 )
130 math = cc.find_library('m')
131 rt = cc.find_library('rt')
132
133 scenefx_files = []
134 scenefx_deps = [
135 wlroots,
136 wayland_server,
137 drm,
138 xkbcommon,
139 pixman,
140 math,
141 rt,
142 ]
143
144 # Tracy
145 if get_option('tracy_enable')
146 internal_features += { 'tracy': true }
147
148 if get_option('buildtype') != 'debugoptimized'
149 warning('Profiling builds should set --buildtype=debugoptimized')
150 endif
151
152 tracy_options = [
153 'default_library=static',
154 'werror=false',
155 'warning_level=0',
156 ]
157 tracy_proj = subproject(
158 'tracy',
159 required: true,
160 default_options: tracy_options
161 )
162 scenefx_deps += tracy_proj.get_variable('tracy_dep')
163 add_project_arguments(
164 [
165 '-DTRACY_ENABLE',
166 '-DTRACY_ON_DEMAND',
167 ],
168 language: 'c',
169 )
170 endif
171
172 subdir('protocol')
173 subdir('render')
174
175 subdir('types')
176 subdir('util')
177
178 subdir('include')
179
180 scenefx_inc = include_directories('include')
181
182 lib_scenefx = library(
183 versioned_name, scenefx_files,
184 dependencies: scenefx_deps,
185 include_directories: [ scenefx_inc ],
186 install: true,
187 )
188
189
190 scenefx = declare_dependency(
191 link_with: lib_scenefx,
192 dependencies: scenefx_deps,
193 include_directories: scenefx_inc,
194 )
195
196 meson.override_dependency(versioned_name, scenefx)
197
198 summary(features + internal_features, bool_yn: true)
199
200 if get_option('examples')
201 subdir('examples')
202 subdir('tinywl')
203 endif
204
205 pkgconfig = import('pkgconfig')
206 pkgconfig.generate(
207 lib_scenefx,
208 name: versioned_name,
209 version: meson.project_version(),
210 description: 'Wlroots effects library',
211 subdirs: versioned_name,
212 )