meson.build 4.69 KB
Newer Older
Drew DeVault's avatar
Drew DeVault committed
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
# Copyright 2019, Collabora, Ltd.
# SPDX-License-Identifier: BSL-1.0

project(
	'xrt',
	['c', 'cpp'],
	version: '0.1.0',
	license: 'BSL-1.0',
	meson_version: '>=0.49.0',
	default_options: [
		'c_std=c11',
		'warning_level=2',
	],
)

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

add_project_arguments(cc.get_supported_arguments([
	'-D_XOPEN_SOURCE=700',
	'-pedantic',
	'-Wall',
	'-Wextra',
	'-Wno-unused-parameter',
]), language: 'c')

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

35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51

#
# Pre-setting these variables
#

build_docs = false
build_tracking = false

v4l2_required = false
hidapi_required = false
openhmd_required = false


#
# Adding dependencies
#

52
53
54
55
56
doxygen = find_program('doxygen', required: get_option('docs'))
if get_option('docs').enabled() or get_option('docs').auto()
	build_docs = true
endif

Drew DeVault's avatar
Drew DeVault committed
57
58
59
60
61
62
63
64
65
66
67
glslangValidator = find_program('glslangValidator')

avcodec = dependency('libavcodec', required: false)
eigen3  = dependency('eigen3')
libjpeg = dependency('libjpeg', required: false)
libusb  = dependency('libusb-1.0', required: false)
opengl  = dependency('gl')
sdl2    = dependency('sdl2', required: get_option('gui'))
udev    = dependency('libudev', required: false)
libuvc  = dependency('libuvc', required: false)
vulkan  = dependency('vulkan')
68
zlib    = dependency('zlib', required: false)
Drew DeVault's avatar
Drew DeVault committed
69

70
71
72
73
74
opencv = dependency('opencv4', required: false)
if not opencv.found()
	opencv = dependency('opencv', required: get_option('tracking'))
endif

Drew DeVault's avatar
Drew DeVault committed
75
76
77
78
79
80
81
82
83
84
pthreads = cc.find_library('pthread', required: true)

if get_option('tracking').enabled() or get_option('tracking').auto()
	build_tracking = opencv.found()
endif

# TODO: make these behave well when not present
x11       = dependency('x11', required: false)
xcb       = dependency('xcb', required: false)
xcb_randr = dependency('xcb-randr', required: false)
85
86
87
88
89
90
91
92
93
94
95

wayland         = dependency('wayland-client', required: false)
wayland_protos  = dependency('wayland-protocols', required: false)
wayland_scanner = dependency('wayland-scanner', required: false)

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
96

97
# For now required on Linux
Jakob Bornecrantz's avatar
Jakob Bornecrantz committed
98
if target_machine.system() == 'linux'
99
100
101
	v4l2_required = true
endif

Drew DeVault's avatar
Drew DeVault committed
102
103
104
105
drivers = get_option('drivers')
if 'ohmd' in drivers
	openhmd_required = true
endif
106
if 'psvr' in drivers
Drew DeVault's avatar
Drew DeVault committed
107
108
109
110
111
112
113
	hidapi_required = true
endif
if 'v4l2' in drivers
	v4l2_required = true
endif

if 'auto' in drivers
114
	drivers += ['psmv', 'hydra', 'hdk']
Drew DeVault's avatar
Drew DeVault committed
115
116
117
endif

openhmd = dependency('openhmd', required: openhmd_required)
118
hidapi  = dependency('hidapi-libusb', required: hidapi_required)
Drew DeVault's avatar
Drew DeVault committed
119
120
121
122
123
124
125
126
127
128
129
130
131
132
v4l2    = dependency('libv4l2', required: v4l2_required)

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

133
134
135
136
137
138
if zlib.found() and ('auto' in drivers or 'vive' in drivers)
	if 'vive' not in drivers
		drivers += ['vive']
	endif
endif

Drew DeVault's avatar
Drew DeVault committed
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
if v4l2.found() and ('auto' in drivers or 'v4l2' in drivers)
	if 'v4l2' not in drivers
		drivers += ['v4l2']
	endif
endif

if drivers.length() == 0 or drivers == ['auto']
	error('You must enable at least one driver.')
endif

if udev.found()
	add_project_arguments('-DXRT_HAVE_LIBUDEV', language: ['c', 'cpp'])
endif

if libusb.found()
	add_project_arguments('-DXRT_HAVE_LIBUSB', language: ['c', 'cpp'])
endif

if opencv.found()
	add_project_arguments('-DXRT_HAVE_OPENCV', language: ['c', 'cpp'])
endif

if libjpeg.found()
	add_project_arguments('-DXRT_HAVE_JPEG', language: ['c', 'cpp'])
endif

if libuvc.found()
	add_project_arguments('-DXRT_HAVE_LIBUVC', language: ['c', 'cpp'])
endif

if avcodec.found()
	add_project_arguments('-DXRT_HAVE_FFMPEG', language: ['c', 'cpp'])
endif

if sdl2.found()
	add_project_arguments('-DXRT_HAVE_SDL2', language: ['c', 'cpp'])
endif

177
178
179
180
181

#
# Go down sub directories
#

Drew DeVault's avatar
Drew DeVault committed
182
183
subdir('src')

184
if build_docs
Drew DeVault's avatar
Drew DeVault committed
185
186
187
	subdir('doc')
endif

188
189
190
191
192

#
# Final bits
#

Drew DeVault's avatar
Drew DeVault committed
193
194
195
196
197
198
199
200
201
202
# 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,
)
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217

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