-
Notifications
You must be signed in to change notification settings - Fork 4
/
meson.build
239 lines (206 loc) · 6.38 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
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
project(
'Xenodon',
'cpp',
version: '0.0.0',
default_options: [
'cpp_std=c++17',
'b_lto=true',
'buildtype=debugoptimized',
]
)
cxx = meson.get_compiler('cpp')
if cxx.get_id() != 'clang' and cxx.get_id() != 'gcc'
error('Compiler not supported')
endif
if host_machine.cpu_family() != 'x86_64'
error('Host machine cpy family is required to be x86_64 (required by Grid::vol_scan)')
endif
if host_machine.endian() != 'little'
error('Host machine endianness is required to be litte (required by Grid::from_tiff)')
endif
# Project sources & resources
sources = [
'src/main.cpp',
'src/main_loop.cpp',
'src/sysinfo.cpp',
'src/convert.cpp',
'src/core/Logger.cpp',
'src/core/Parser.cpp',
'src/core/arg_parse.cpp',
'src/graphics/core/Instance.cpp',
'src/graphics/core/PhysicalDevice.cpp',
'src/graphics/core/Device.cpp',
'src/graphics/core/Swapchain.cpp',
'src/graphics/memory/Image.cpp',
'src/graphics/memory/Texture3D.cpp',
'src/graphics/shader/Shader.cpp',
'src/graphics/command/CommandPool.cpp',
'src/graphics/utility.cpp',
'src/render/Renderer.cpp',
'src/render/RenderContext.cpp',
'src/render/MultiplexRenderer.cpp',
'src/render/SvoRaytraceAlgorithm.cpp',
'src/render/DdaRaytraceAlgorithm.cpp',
'src/render/RenderStats.cpp',
'src/camera/OrbitCameraController.cpp',
'src/camera/ScriptCameraController.cpp',
'src/backend/backend.cpp',
'src/backend/SwapImage.cpp',
'src/backend/RenderDevice.cpp',
'src/backend/headless/headless.cpp',
'src/backend/headless/HeadlessDisplay.cpp',
'src/backend/headless/HeadlessConfig.cpp',
'src/backend/headless/HeadlessOutput.cpp',
'src/model/Grid.cpp',
'src/model/Octree.cpp'
]
shaders = [
'resources/dda.comp',
'resources/svo_naive.comp',
'resources/esvo.comp',
'resources/svo_df.comp',
'resources/svo_rope.comp'
]
resources = [
'resources/help.txt',
'resources/help/help.txt',
'resources/help/sysinfo.txt',
'resources/help/convert.txt',
'resources/help/render.txt',
'resources/help/xorg_multi_gpu.txt',
'resources/help/headless_config.txt',
'resources/help/direct_config.txt',
]
add_project_arguments(
[
'-Wconversion',
'-Wall',
'-Wextra',
'-Wno-unused-parameter' # silence warnigns generated by vulkan.hpp
],
language: 'cpp'
)
# C++17 <filesystem> support
add_project_link_arguments(
'-lstdc++fs',
language: 'cpp'
)
# Project-wide dependencies
vk_dep = dependency('vulkan', method: 'system')
dependencies = [
vk_dep,
dependency('libtiff-4'),
subproject('fmt').get_variable('fmt_dep'),
subproject('lodepng').get_variable('lodepng_dep')
]
# Generate version.h
versions = meson.project_version().split('.')
conf = configuration_data()
conf.set_quoted('NAME', meson.project_name())
conf.set('MAJOR', versions[0])
conf.set('MINOR', versions[1])
conf.set('PATCH', versions[2])
configure_file(
input: 'version.in.h',
output: 'version.h',
configuration: conf
)
# Add configuration for the direct backend
if get_option('present-direct').enabled()
message('Building with direct backend')
# Direct presenting requires raw linux input, and is thus
# not supported on other platforms
if host_machine.system() != 'linux'
error('Direct display system requires linux')
endif
add_project_arguments('-DXENODON_PRESENT_DIRECT', language: 'cpp')
sources += [
'src/backend/direct/direct.cpp',
'src/backend/direct/DirectDisplay.cpp',
'src/backend/direct/DirectOutput.cpp',
'src/backend/direct/ScreenGroup.cpp',
'src/backend/direct/DirectConfig.cpp',
'src/backend/direct/input/LinuxInput.cpp',
'src/backend/direct/input/linux_translate_key.cpp'
]
dependencies += [
dependency('threads')
]
endif
# Add configuration for the xorg backend
if get_option('present-xorg').enabled()
message('Building with xorg presenting support')
# Even though were not using X11 but XCB, we still need this header for the
# key symbol definitions.
if not cxx.has_header('X11/keysym.h')
error('X11 keysym header not found (X11/keysym.h)')
endif
add_project_arguments(
[
'-DXENODON_PRESENT_XORG',
'-DVK_USE_PLATFORM_XCB_KHR'
],
language: 'cpp'
)
sources += [
'src/backend/xorg/xorg.cpp',
'src/backend/xorg/XorgDisplay.cpp',
'src/backend/xorg/XorgOutput.cpp',
'src/backend/xorg/Window.cpp',
'src/backend/xorg/XorgMultiGpuConfig.cpp',
'src/backend/xorg/xorg_translate_key.cpp'
]
dependencies += [
dependency('xcb', method: 'pkg-config'),
dependency('xcb-keysyms', method: 'pkg-config'),
dependency('xcb-xkb', method: 'pkg-config')
]
endif
# Silence gcc warnings about vulkan-hpp's memcpy
if cxx.get_id() == 'gcc'
add_project_arguments(['-Wno-class-memaccess'], language: 'cpp')
endif
if not cxx.has_header('vulkan/vulkan.h', dependencies: vk_dep)
error('Vulkan C headers not found (vulkan/vulkan.h)')
endif
# Check if vulkan-hpp is installed.
if not cxx.has_header('vulkan/vulkan.hpp', dependencies: vk_dep)
error('Vulkan C++ headers not found (vulkan/vulkan.hpp)')
endif
# GLSL -> SPIR-V compiler
# glslc should be included in the LunarG SDK
glslc = find_program('glslc')
spv_gen = generator(
glslc,
output: '@[email protected]',
arguments: ['--target-env=vulkan1.1', '@INPUT@', '-o', '@OUTPUT@']
)
# Compile resources into the binary
generate_resources = find_program('tools/generate_resources.py')
resources_command = [generate_resources, '-i', '@OUTPUT0@', '-s', '@OUTPUT1@']
inputs = []
foreach resource : resources
resources_command += ['-f', '@INPUT@0@@'.format(inputs.length()), resource]
inputs += resource
endforeach
foreach shader : shaders
resources_command += ['-f', '@INPUT@0@@'.format(inputs.length()), shader]
inputs += spv_gen.process(shader)
endforeach
resources_host = custom_target(
'gen-resources',
input: inputs,
output: ['resources.h', 'resources.S'],
command: resources_command
)
dependencies += declare_dependency(
sources: resources_host
)
# Main binary
executable('xenodon', sources,
install: true,
build_by_default: true,
dependencies: dependencies,
include_directories: include_directories('src'),
link_args: '-g'
)