-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmeson.build
218 lines (188 loc) · 4.99 KB
/
meson.build
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
project('ny', ['c', 'cpp'],
license: 'BSL',
version: '0.1.0',
meson_version: '>=0.42',
default_options: ['cpp_std=c++1z', 'c_std=c11', 'warning_level=3'])
# TODO:
# android:
# - disable x11/wayland/winapi dependency checks, maybe error with wrong options
# options
# can be 'true', 'false' or 'auto'
# if an options is 'auto' it will be set depending
# on whether the required dpendencies are avilable
op_enable_x11 = get_option('enable_x11')
op_enable_wayland = get_option('enable_wayland')
op_enable_winapi = get_option('enable_winapi')
op_enable_vulkan = get_option('enable_vulkan')
op_enable_gl = get_option('enable_gl')
op_enable_egl = get_option('enable_egl')
examples = get_option('examples')
android = get_option('android')
# default arrguments
# warnings and stuff
add_project_arguments(
'-Wno-non-virtual-dtor',
'-Wno-missing-braces', # TODO: only needed for clang
language: 'cpp')
# TODO: fix on windows, see dlg notes
# project-specific stuff
# currently set dlg path only on linux since on windows
# it causes errors with backslashes
if build_machine.system() != 'windows'
add_project_arguments(
'-DDLG_BASE_PATH="@0@"'.format(meson.source_root()),
language: 'cpp')
endif
# auto option resolution
# always required deps
dep_threads = dependency('threads')
dep_dlg = dependency('dlg', fallback: ['dlg', 'dlg_dep'])
dep_nytl = dependency('nytl', fallback: ['nytl', 'nytl_dep'])
deps = [
dep_threads,
dep_dlg,
dep_nytl]
# vulkan
if op_enable_vulkan == 'false'
enable_vulkan = false
else
dep_vulkan = dependency('vulkan', required: op_enable_vulkan == 'true')
enable_vulkan = dep_vulkan.found()
deps += dep_vulkan
endif
# gl
if op_enable_gl == 'false'
enable_gl = false
else
dep_gl = dependency('gl', required: op_enable_gl == 'true')
enable_gl = dep_gl.found()
deps += dep_gl
endif
# egl
if op_enable_egl == 'false'
enable_egl = false
elif not android
dep_egl = dependency('egl', required: op_enable_egl == 'true')
enable_egl = dep_egl.found()
deps += dep_egl
elif android
dep_egl = meson.get_compiler('c').find_library('EGL', required: false)
enable_egl = dep_egl.found()
deps += dep_egl
endif
dep_xkbcommon = dependency('xkbcommon', required: false)
# winapi
if op_enable_winapi == 'auto'
enable_winapi = build_machine.system() == 'windows'
else
enable_winapi = op_enable_winapi == 'true'
endif
# x11
if op_enable_x11 == 'false'
enable_x11 = false
else
req = op_enable_x11 == 'true'
if req and not dep_xkbcommon.found()
error('x11 backend requires xkbcommon')
endif
dep_x11 = dependency('x11', required: req)
dep_x11xcb = dependency('x11-xcb', required: req)
dep_xi = dependency('xi', required: req)
dep_xcursor = dependency('xcursor', required: req)
dep_xcb = dependency('xcb', required: req)
dep_xcbewmh = dependency('xcb-ewmh', required: req)
dep_xcbicccm = dependency('xcb-icccm', required: req)
dep_xcbshm = dependency('xcb-shm', required: req)
dep_xcbxkb = dependency('xcb-xkb', required: req)
dep_xkbcommonx11 = dependency('xkbcommon-x11', required: req)
x11_deps = [
dep_x11,
dep_x11xcb,
dep_xi,
dep_xcursor,
dep_xcb,
dep_xcbewmh,
dep_xcbicccm,
dep_xcbshm,
dep_xcbxkb,
dep_xkbcommon,
dep_xkbcommonx11]
enable_x11 = true
foreach dep : x11_deps
if not dep.found()
enable_x11 = false
endif
endforeach
if enable_x11
deps += x11_deps
if enable_gl
deps += dep_gl
endif
endif
endif
# wayland
if op_enable_wayland == 'false'
enable_wayland = false
else
required = op_enable_wayland == 'true'
if required and not dep_xkbcommon.found()
error('wayland requires xkbcommon')
endif
dep_wl = dependency('wayland-client', required: required)
dep_wlcursor = dependency('wayland-cursor', required: required)
wl_deps = [dep_xkbcommon, dep_wl, dep_wlcursor]
enable_wayland = true
foreach dep : wl_deps
if not dep.found()
enable_wayland = false
endif
endforeach
if enable_wayland
deps += wl_deps
if enable_egl
deps += dep_egl
deps += dependency('wayland-egl')
endif
endif
endif
# winapi deps
if enable_winapi
deps += meson.get_compiler('cpp').find_library('Dwmapi')
deps += meson.get_compiler('cpp').find_library('Shlwapi')
if enable_gl
deps += dep_gl
endif
endif
if not enable_winapi and not enable_wayland and not enable_x11 and not android
message('WARNING: building ny without any valid backends')
endif
ny_inc = include_directories('include')
ny_inc_private = include_directories('src')
# subdirs
subdir('include/ny')
subdir('src/ny')
# dependency
ny_dep = declare_dependency(
include_directories: ny_inc,
dependencies: deps,
link_with: ny_lib)
# examples
# must come after dependency
if examples
subdir('src/examples')
endif
# pkgconfig
# TODO: make sure requires is correct (test it)
# test the packageconfig with an external project
if not android
pkg = import('pkgconfig')
pkg_dirs = ['ny']
pkg.generate(
name: 'ny',
requires: ['nytl'],
libraries: ny_lib,
filebase: 'ny',
subdirs: pkg_dirs,
version: meson.project_version(),
description: 'C++17 window abstraction')
endif