Skip to content

Commit 2ad76ff

Browse files
committed
meson: support building glimpse_viewer for iOS
1 parent 42d72c6 commit 2ad76ff

File tree

2 files changed

+72
-13
lines changed

2 files changed

+72
-13
lines changed

ios-11-arm64-cross-file.txt

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
[binaries]
2+
name = 'arm-apple-darwin11'
3+
c = 'arm-apple-darwin11-clang'
4+
objc = 'arm-apple-darwin11-clang'
5+
cpp = 'arm-apple-darwin11-clang++'
6+
ar = 'arm-apple-darwin11-ar'
7+
ld = 'arm-apple-darwin11-ld'
8+
strip = 'arm-apple-darwin11-strip'
9+
10+
[host_machine]
11+
system = 'darwin'
12+
cpu_family = 'arm'
13+
cpu = 'arm64'
14+
endian = 'little'
15+
16+
[properties]
17+
18+
objc_args = [ '-ObjC', '-fobjc-arc', '-fmodules', '-gmodules' ]
19+
c_args = [ '-fmodules', '-gmodules' ]
20+
cpp_args = [ '-fmodules', '-gmodules' ]
21+
22+
# As a hacky workaround for not being able to query the binaries
23+
# we need to specify the strip tool again for our install script
24+
_strip_binary = 'arm-apple-darwin11-strip'

meson.build

+48-13
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ project('glimpse', ['c', 'cpp', 'java'],
33
default_options: ['c_std=gnu11', 'cpp_std=c++14'])
44

55
use_system_libs = get_option('use_system_libs')
6+
if meson.is_cross_build()
7+
use_system_libs = false
8+
endif
69

710
compiler = meson.get_compiler('c')
811
python3 = import('python3').find_python()
@@ -36,6 +39,13 @@ else
3639
platform_android = false
3740
endif
3841

42+
if compiler.get_define('__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__') != ''
43+
platform_ios = true
44+
else
45+
platform_ios = false
46+
endif
47+
48+
3949
threads_dep = dependency('threads')
4050
maths_dep = compiler.find_library('m', required : false)
4151

@@ -113,7 +123,6 @@ endif
113123
client_api_defines += [ '-DUSE_FREENECT' ]
114124

115125
glfw_dep = dependency('glfw3', required: false)
116-
epoxy_dep = dependency('epoxy', fallback: [ 'libepoxy', 'libepoxy_dep' ])
117126
snappy_dep = dependency('snappy', required: false)
118127

119128
imgui_src = [
@@ -147,12 +156,16 @@ client_api_src = [
147156
client_api_deps = [
148157
glm_dep,
149158
libpng_dep,
150-
epoxy_dep,
151159
dlib_dep,
152160
pcl_deps,
153161
freenect_dep,
154162
]
155163

164+
#if platform_ios == false
165+
epoxy_dep = dependency('epoxy', fallback: [ 'libepoxy', 'libepoxy_dep' ])
166+
client_api_deps += epoxy_dep
167+
#endif
168+
156169
if uw_dep.found()
157170
client_api_deps += uw_dep
158171
client_api_defines += '-DUSE_LIBUNWIND=1'
@@ -236,18 +249,16 @@ if unity_enabled
236249
endif
237250

238251
need_glimpse_native_jar = false
239-
if compiler.get_define('__ANDROID__') != ''
252+
if platform_android == true
240253
glfm_sp = subproject('glfm')
241254
glfm_dep = glfm_sp.get_variable('glfm_dep')
242-
glfm_defines = [ '-DGLFM_INCLUDE_ES3' ]
243-
client_api_defines += '-DUSE_GLFM'
255+
256+
viewer_deps = client_api_deps + glfm_dep
257+
viewer_defines = client_api_defines + [ '-DUSE_GLFM' ]
244258

245259
if tango_enabled
246-
viewer_deps = client_api_deps + [ tango_deps, glfm_dep ]
247-
viewer_defines = client_api_defines + glfm_defines + [ '-DUSE_TANGO=1' ]
248-
else
249-
viewer_deps = client_api_deps + [ glfm_dep ]
250-
viewer_defines = client_api_defines + glfm_defines
260+
viewer_deps += tango_deps
261+
viewer_defines += [ '-DUSE_TANGO=1' ]
251262
endif
252263

253264
use_asset_manager = get_option('use_asset_manager')
@@ -269,6 +280,30 @@ endif
269280

270281
subdir('src/java')
271282

283+
if platform_ios == true
284+
glfm_sp = subproject('glfm')
285+
glfm_dep = glfm_sp.get_variable('glfm_dep')
286+
287+
viewer_deps = client_api_deps + [ glfm_dep ]
288+
viewer_defines = client_api_defines + [ '-DUSE_GLFM' ]
289+
290+
imgui_src += 'src/imgui/imgui_impl_glfm_gles3.cpp'
291+
292+
executable('glimpse_viewer',
293+
[ 'src/glimpse_viewer.cc' ] + client_api_src + imgui_src,
294+
include_directories: inc,
295+
dependencies: viewer_deps,
296+
c_args: viewer_defines,
297+
cpp_args: viewer_defines,
298+
link_args: [
299+
'-framework', 'Foundation',
300+
'-framework', 'OpenGLES',
301+
'-framework', 'CoreGraphics',
302+
'-framework', 'QuartzCore',
303+
'-framework', 'UIKit'
304+
])
305+
endif
306+
272307
if not meson.is_cross_build()
273308

274309
executable('image-pre-processor',
@@ -377,14 +412,14 @@ if snappy_dep.found()
377412
endif
378413

379414
if glfw_dep.found() and epoxy_dep.found()
380-
client_api_defines += '-DUSE_GLFW'
415+
viewer_defines = client_api_defines + '-DUSE_GLFW'
381416
imgui_src += 'src/imgui/imgui_impl_glfw_gles3.cpp'
382417
executable('glimpse_viewer',
383418
[ 'src/glimpse_viewer.cc' ] + client_api_src + imgui_src,
384419
include_directories: inc,
385420
dependencies: client_api_deps + [ glfw_dep ],
386-
c_args: client_api_defines,
387-
cpp_args: client_api_defines)
421+
c_args: viewer_defines,
422+
cpp_args: viewer_defines)
388423
endif
389424

390425
endif # is_cross_build

0 commit comments

Comments
 (0)