-
Notifications
You must be signed in to change notification settings - Fork 39
/
Copy pathmeson.build
205 lines (178 loc) · 5.21 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
# Copyright 2021-2025 David Robillard <d@drobilla.net>
# SPDX-License-Identifier: 0BSD OR ISC
data_dir = get_option('prefix') / get_option('datadir') / 'pugl-0'
example_defines = ['-DPUGL_DATA_DIR="@0@"'.format(data_dir)]
stub_examples = [
'pugl_print_events.c',
]
gl_examples = [
'pugl_clipboard_demo.c',
'pugl_cpp_demo.cpp',
'pugl_cursor_demo.c',
'pugl_embed_demo.c',
'pugl_shader_demo.c',
'pugl_window_demo.c',
]
cairo_examples = [
'pugl_cairo_demo.c',
'pugl_management_demo.c',
]
vulkan_examples = [
'pugl_vulkan_cpp_demo.cpp',
'pugl_vulkan_demo.c',
]
# Suppress some additional C warnings in examples
example_c_args = []
if get_option('warning_level') == 'everything'
if cc.get_id() == 'clang'
example_c_args += [
'-Wno-float-equal',
'-Wno-reserved-id-macro',
'-Wno-reserved-identifier',
]
elif cc.get_id() == 'gcc'
example_c_args += [
'-Wno-float-equal',
]
endif
example_c_args = cc.get_supported_arguments(example_c_args)
endif
# Suppress some additional C++ warnings in examples
example_cpp_args = []
if get_option('warning_level') == 'everything' and is_variable('cpp')
if cpp.get_id() == 'clang'
example_cpp_args += [
'-Wno-documentation', # Cairo
'-Wno-documentation-unknown-command', # Cairo
'-Wno-old-style-cast',
'-Wno-switch-enum',
]
if host_machine.system() == 'windows'
example_cpp_args += [
'-Wno-deprecated-declarations',
'-Wno-format-nonliteral',
'-Wno-nonportable-system-include-path',
]
endif
elif cpp.get_id() == 'gcc'
example_cpp_args += [
'-Wno-effc++',
'-Wno-old-style-cast',
'-Wno-switch-default',
'-Wno-switch-enum',
'-Wno-unused-const-variable',
'-Wno-useless-cast',
]
elif cpp.get_id() == 'msvc'
example_cpp_args += [
'/wd4355', # 'this' used in base member initializer list
'/wd4868', # may not enforce left-to-right evaluation order
'/wd5246', # subobject initialization should be wrapped in braces
]
endif
example_cpp_args = cpp.get_supported_arguments(example_cpp_args)
endif
subdir('shaders')
if host_machine.system() == 'darwin'
# On Darwin, build examples as application bundles (required to work properly)
subdir('pugl_clipboard_demo.app')
if cairo_dep.found()
subdir('pugl_cairo_demo.app')
subdir('pugl_management_demo.app')
endif
if opengl_dep.found()
subdir('pugl_cpp_demo.app')
subdir('pugl_cursor_demo.app')
subdir('pugl_embed_demo.app')
subdir('pugl_shader_demo.app')
subdir('pugl_window_demo.app')
endif
if vulkan_dep.found()
subdir('pugl_vulkan_cpp_demo.app')
subdir('pugl_vulkan_demo.app')
endif
else
# On all other platforms, build examples as simple programs
# Build stub examples
foreach example : stub_examples
source = [example]
target = example.split('.')[0]
dependencies = [pugl_dep, pugl_stub_dep, puglutil_dep]
defines = []
executable(
target,
source,
c_args: example_defines + example_c_args + defines,
cpp_args: example_defines + example_cpp_args + defines,
dependencies: dependencies,
implicit_include_directories: false,
)
endforeach
# Build GL examples
if opengl_dep.found()
foreach example : gl_examples
source = [example]
target = example.split('.')[0]
dependencies = [pugl_dep, pugl_gl_dep, puglutil_dep]
defines = []
if target == 'pugl_shader_demo'
source += ['file_utils.c', 'glad/glad.c']
dependencies += [dl_dep]
defines += ['-D_POSIX_C_SOURCE=200809L']
elif target == 'pugl_print_events'
dependencies += [pugl_stub_dep]
elif target == 'pugl_cpp_demo'
if not is_variable('puglpp_dep')
continue
endif
dependencies += [puglpp_dep]
endif
executable(
target,
source,
c_args: example_defines + example_c_args + defines,
cpp_args: example_defines + example_cpp_args + defines,
dependencies: dependencies,
implicit_include_directories: false,
)
endforeach
endif
# Build Cairo examples
if cairo_dep.found()
foreach example : cairo_examples
target = example.split('.')[0]
executable(
target,
example,
c_args: example_defines + example_c_args + cairo_args,
dependencies: [pugl_dep, pugl_cairo_dep, puglutil_dep],
implicit_include_directories: false,
)
endforeach
endif
# Build Vulkan examples
if vulkan_dep.found()
foreach example : vulkan_examples
source = [example]
target = example.split('.')[0]
dependencies = [dl_dep, pugl_vulkan_dep, puglutil_dep]
defines = []
if target == 'pugl_vulkan_cpp_demo'
if not is_variable('puglpp_dep')
continue
endif
source += ['file_utils.c']
defines += ['-D_POSIX_C_SOURCE=200809L']
dependencies += [puglpp_dep]
endif
executable(
target,
source,
c_args: example_defines + example_c_args + defines,
cpp_args: example_defines + example_cpp_args + defines,
dependencies: dependencies,
implicit_include_directories: false,
)
endforeach
endif
endif