meson.build 6 KB
Newer Older
1
# Copyright 2019-2020, Collabora, Ltd.
Drew DeVault's avatar
Drew DeVault committed
2
3
4
5
6
# SPDX-License-Identifier: BSL-1.0

project(
	'xrt',
	['c', 'cpp'],
Jakob Bornecrantz's avatar
Jakob Bornecrantz committed
7
	version: '0.4.0',
Drew DeVault's avatar
Drew DeVault committed
8
9
10
11
	license: 'BSL-1.0',
	meson_version: '>=0.49.0',
	default_options: [
		'c_std=c11',
12
		'warning_level=3',
Drew DeVault's avatar
Drew DeVault committed
13
14
15
16
17
18
19
20
21
	],
)

cc = meson.get_compiler('c')
cpp = meson.get_compiler('cpp')

add_project_arguments(cc.get_supported_arguments([
	'-D_XOPEN_SOURCE=700',
	'-Wno-unused-parameter',
22
23
	'-Werror-implicit-function-declaration',
	'-Werror=incompatible-pointer-types'
Drew DeVault's avatar
Drew DeVault committed
24
25
26
27
28
29
30
31
]), language: 'c')

add_project_arguments(cpp.get_supported_arguments([
	'-D_XOPEN_SOURCE=700',
	'-Wno-unused-parameter',
	'-Wno-deprecated-copy', # Eigen
]), language: 'cpp')

32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47

#
# Pre-setting these variables
#

build_tracking = false

v4l2_required = false
hidapi_required = false
openhmd_required = false


#
# Adding dependencies
#

48
# When docs are disabled, doxygen will always appear as "not found"
49
doxygen = find_program('doxygen', required: get_option('docs'))
50
build_docs = doxygen.found()
51

Drew DeVault's avatar
Drew DeVault committed
52
53
glslangValidator = find_program('glslangValidator')

Jakob Bornecrantz's avatar
Jakob Bornecrantz committed
54
pthreads = cc.find_library('pthread', required: true)
55
rt = cc.find_library('rt', required: true)
Jakob Bornecrantz's avatar
Jakob Bornecrantz committed
56

57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
avcodec  = dependency('libavcodec', required: false)
egl      = dependency('egl', required: get_option('egl'))
egl      = egl.partial_dependency(includes: true)
eigen3   = dependency('eigen3')
libjpeg  = dependency('libjpeg', required: false)
libusb   = dependency('libusb-1.0', required: false)
opengl   = dependency('gl', required: get_option('opengl'))
opengles = dependency('glesv2', required: get_option('opengles'))
rs       = dependency('realsense2', required: false)
sdl2     = dependency('sdl2', required: get_option('gui'))
udev     = dependency('libudev', required: false)
libuvc   = dependency('libuvc', required: false)
vulkan   = dependency('vulkan', required: true)
zlib     = dependency('zlib', required: false)
survive  = dependency('survive', required: false)
72
dbus     = dependency('dbus-1', required: get_option('dbus'))
Drew DeVault's avatar
Drew DeVault committed
73

74
75
76
77
78
opencv = dependency('opencv4', required: false)
if not opencv.found()
	opencv = dependency('opencv', required: get_option('tracking'))
endif

Drew DeVault's avatar
Drew DeVault committed
79
80
81
82
83
if get_option('tracking').enabled() or get_option('tracking').auto()
	build_tracking = opencv.found()
endif

# TODO: make these behave well when not present
84
x11       = dependency('x11', required: get_option('xlib'))
85
x11_xcb   = dependency('x11-xcb', required: get_option('xlib'))
86
87
xcb       = dependency('xcb', required: get_option('xcb'))
xcb_randr = dependency('xcb-randr', required: get_option('xcb'))
88

89
90
91
wayland         = dependency('wayland-client', required: get_option('wayland'))
wayland_protos  = dependency('wayland-protocols', required: get_option('wayland'))
wayland_scanner = dependency('wayland-scanner', required: get_option('wayland'))
92
93
94
95
96
97
98

if wayland_scanner.found()
	wayland_scanner = find_program(
		wayland_scanner.get_pkgconfig_variable('wayland_scanner'),
		native: true,
	)
endif
Drew DeVault's avatar
Drew DeVault committed
99

100
101
102
103
104
build_opengl = false
if get_option('opengl').enabled() or get_option('opengl').auto()
        build_opengl = opengl.found()
endif

105
106
107
108
109
build_opengles = false
if get_option('opengles').enabled() or get_option('opengles').auto()
        build_opengles = opengles.found() and egl.found()
endif

110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125

build_egl = false
if get_option('egl').enabled() or get_option('egl').auto()
        build_egl = opengl.found() and egl.found()
endif

build_xlib = false
if get_option('xlib').enabled() or get_option('xlib').auto()
        build_xlib = x11.found()
endif

build_xcb = false
if get_option('xcb').enabled() or get_option('xcb').auto()
        build_xcb = xcb.found()
endif

126
build_xcb_xrandr_direct = build_xcb and build_xlib and xcb_randr.found() and x11_xcb.found()
127
128
129
130
131
132

build_wayland = false
if get_option('wayland').enabled() or get_option('wayland').auto()
        build_wayland = wayland.found() and wayland_protos.found() and wayland_scanner.found()
endif

133
# For now required on Linux
Jakob Bornecrantz's avatar
Jakob Bornecrantz committed
134
if target_machine.system() == 'linux'
135
136
137
	v4l2_required = true
endif

Drew DeVault's avatar
Drew DeVault committed
138
139
140
141
drivers = get_option('drivers')
if 'ohmd' in drivers
	openhmd_required = true
endif
142
if 'psvr' in drivers
Drew DeVault's avatar
Drew DeVault committed
143
144
145
146
147
148
149
	hidapi_required = true
endif
if 'v4l2' in drivers
	v4l2_required = true
endif

if 'auto' in drivers
150
	drivers += ['dummy', 'hdk', 'hydra', 'ns', 'psmv']
Drew DeVault's avatar
Drew DeVault committed
151
152
153
endif

openhmd = dependency('openhmd', required: openhmd_required)
154
hidapi  = dependency('hidapi-libusb', required: hidapi_required)
155
156

has_v4l2_header =  cc.has_header('linux/v4l2-common.h')
Drew DeVault's avatar
Drew DeVault committed
157
158
159
160
161
162
163
164
165
166
167
168
169

if openhmd.found() and ('auto' in drivers or 'ohmd' in drivers)
	if 'ohmd' not in drivers
		drivers += ['ohmd']
	endif
endif

if hidapi.found() and ('auto' in drivers or 'psvr' in drivers or 'hdk' in drivers)
	if 'psvr' not in drivers
		drivers += ['psvr']
	endif
endif

170
171
172
173
174
175
if zlib.found() and ('auto' in drivers or 'vive' in drivers)
	if 'vive' not in drivers
		drivers += ['vive']
	endif
endif

Jakob Bornecrantz's avatar
Jakob Bornecrantz committed
176
177
178
179
180
181
if rs.found() and ('auto' in drivers or 'rs' in drivers)
	if 'rs' not in drivers
		drivers += ['rs']
	endif
endif

182
if has_v4l2_header and ('auto' in drivers or 'v4l2' in drivers)
Drew DeVault's avatar
Drew DeVault committed
183
184
185
186
187
	if 'v4l2' not in drivers
		drivers += ['v4l2']
	endif
endif

Christoph Haag's avatar
Christoph Haag committed
188
if survive.found() and ('survive' in drivers)
189
190
191
	if 'survive' not in drivers
		drivers += ['survive']
	endif
Christoph Haag's avatar
Christoph Haag committed
192
193
endif

194
195
196
197
198
199
200
201
202
203
if not get_option('dbus').disabled() and dbus.found()
	if 'daydream' not in drivers
		drivers += ['daydream']
	endif

	if 'arduino' not in drivers
		drivers += ['arduino']
	endif
endif

Drew DeVault's avatar
Drew DeVault committed
204
205
206
207
if drivers.length() == 0 or drivers == ['auto']
	error('You must enable at least one driver.')
endif

208
209
210
211
#
# Go down sub directories
#

Drew DeVault's avatar
Drew DeVault committed
212
213
subdir('src')

214
if build_docs
Drew DeVault's avatar
Drew DeVault committed
215
216
217
	subdir('doc')
endif

218
219
220
221
222

#
# Final bits
#

Drew DeVault's avatar
Drew DeVault committed
223
224
225
226
227
228
229
230
231
232
# This is here so that it gets emitted in the top-level build directory
manifest_devconf = configuration_data()
# https://github.com/mesonbuild/meson/issues/5940
manifest_devconf.set('runtime_path', openxr.full_path())

manifest_dev_json = configure_file(
	input: manifest_in,
	output: 'openxr_monado-dev.json',
	configuration: manifest_devconf,
)
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247

message('Configuration done!')
message('    drivers:  ' + ', '.join(drivers))

if build_docs
	message('    docs:     yes')
else
	message('    docs:     no')
endif

if build_tracking
	message('    tracking: yes')
else
	message('    tracking: no')
endif