Skip to content

Commit 8399b0c

Browse files
committed
Support building Glimpse Viewer on Windows
This adds support for cross compiling Glimpse Viewer and json-to-rdt from Linux or OSX using clang and lld. It depends on building a 'windows-sdk/' SDK on Windows to package up the pre-requisite system headers and libraries using the windows-sdk-build.py script. The script should be run from Ubuntu/WSL with Visual Studio 2017 Community Edition installed along with the Windows 10 SDK and assuming your windows installation is found under /mnt/c: $ ./windows-sdk-build.py Meson can then be run like: $ meson --cross-file ../windows-sdk/meson/windows-x64-debug-cross-file.txt or: $ meson --cross-file ../windows-sdk/meson/windows-x64-release-cross-file.txt \ --buildtype release
1 parent a5221f9 commit 8399b0c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+27140
-14260
lines changed

.gitignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,24 @@ tree?.json
2828
/src/python/glimpse.py
2929
/src/python/glimpse_wrap.cpp
3030
/subprojects/boost_1_65_1
31+
/subprojects/boost_1_69_0
3132
/subprojects/dlib
3233
/subprojects/eigen-git-mirror-3.3.4
34+
/subprojects/flann
3335
/subprojects/flann-1.9.1
3436
/subprojects/glm-0.9.9-a2
37+
/subprojects/glfw
38+
/subprojects/glfm
39+
/subprojects/libepoxy
40+
/subprojects/libfreenect
41+
/subprojects/libfreenect-glimpse
3542
/subprojects/libpng-1.6.17
3643
/subprojects/pcl
3744
/subprojects/packagecache/0.9.9-a2.tar.gz
3845
/subprojects/packagecache/1.9.1.tar.gz
3946
/subprojects/packagecache/boost_1_65_1.tar.bz2
47+
/subprojects/packagecache/boost_1_69_0.tar.bz2
4048
/subprojects/packagecache/eigen-git-mirror-3.3.4.zip
4149
/subprojects/packagecache/libpng-1.6.17.tar.xz
4250
/subprojects/packagecache/tmp*
51+
/subprojects/zlib-1.2.8

meson.build

Lines changed: 79 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,19 @@ endif
8181
threads_dep = dependency('threads')
8282
maths_dep = compiler.find_library('m', required : false)
8383

84+
# Not sure why Meson doesn't support a way to append include directories :/
85+
if host_machine.system() == 'windows'
8486
inc = include_directories(
8587
'src',
88+
'src/win32',
8689
'src/imgui',
8790
'src/UnityPluginAPI')
91+
else
92+
inc = include_directories(
93+
'src',
94+
'src/imgui',
95+
'src/UnityPluginAPI')
96+
endif
8897

8998
dlib_sp = subproject('dlib')
9099
dlib_dep = dlib_sp.get_variable('dlib_dep')
@@ -155,17 +164,28 @@ if not freenect_dep.found()
155164
endif
156165
client_api_defines += [ '-DUSE_FREENECT' ]
157166

158-
glfw_dep = dependency('glfw3', required: false)
167+
glfw_dep = dependency('glfw3', fallback: [ 'glfw', 'glfw_dep' ], required: false)
159168
snappy_dep = dependency('snappy', required: false)
160169

161170
imgui_src = [
162171
'src/imgui/imgui.cpp',
163172
'src/imgui/imgui_demo.cpp',
164173
'src/imgui/imgui_draw.cpp',
174+
'src/imgui/imgui_widgets.cpp',
165175
'src/imgui/profiler.cpp',
166176
'src/imgui/timer.cpp',
167177
]
168178

179+
if host_machine.system() == 'windows'
180+
getopt_src = [ 'src/getopt-compat.c' ]
181+
getline_src = [ 'src/getline-compat.c' ]
182+
basename_src = [ 'src/basename-compat.c' ]
183+
else
184+
getopt_src = []
185+
getline_src = []
186+
basename_src = []
187+
endif
188+
169189
client_api_src = [
170190
'src/glimpse_properties.cc',
171191
'src/glimpse_context.cc',
@@ -177,6 +197,8 @@ client_api_src = [
177197
'src/glimpse_log.c',
178198
'src/glimpse_gl.c',
179199
'src/glimpse_target.cc',
200+
'src/glimpse_mutex.c',
201+
'src/glimpse_os.c',
180202

181203
'src/infer_labels.cc',
182204
'src/joints_inferrer.cc',
@@ -188,7 +210,7 @@ client_api_src = [
188210

189211
'src/tinyexr.cc',
190212
'src/parson.c',
191-
]
213+
] + basename_src + getline_src
192214

193215
client_api_deps = [
194216
glm_dep,
@@ -328,7 +350,10 @@ if platform_android == true
328350
glfm_dep = glfm_sp.get_variable('glfm_dep')
329351

330352
viewer_deps = client_api_deps + [ glfm_dep ]
331-
viewer_defines = client_api_defines + [ '-DUSE_GLFM' ]
353+
viewer_defines = client_api_defines + [
354+
'-DUSE_GLFM',
355+
'-DIMGUI_IMPL_OPENGL_LOADER_CUSTOM=<epoxy/gl.h>'
356+
]
332357

333358
if tango_enabled
334359
viewer_deps += tango_deps
@@ -340,7 +365,8 @@ if platform_android == true
340365
viewer_defines += [ '-DUSE_ANDROID_ASSET_MANAGER_API' ]
341366
endif
342367

343-
imgui_src += 'src/imgui/imgui_impl_glfm_gles3.cpp'
368+
imgui_src += 'src/imgui/imgui_impl_glfm.cpp'
369+
imgui_src += 'src/imgui/imgui_impl_opengl3.cpp'
344370

345371
android_viewer = shared_library('glimpse_viewer_android',
346372
[ 'src/glimpse_viewer.cc' ] + client_api_src + imgui_src,
@@ -359,9 +385,13 @@ if platform_ios == true
359385
glfm_dep = glfm_sp.get_variable('glfm_dep')
360386

361387
viewer_deps = client_api_deps + [ glfm_dep ]
362-
viewer_defines = client_api_defines + [ '-DUSE_GLFM' ]
388+
viewer_defines = client_api_defines + [
389+
'-DUSE_GLFM',
390+
'-DIMGUI_IMPL_OPENGL_LOADER_CUSTOM=<epoxy/gl.h>'
391+
]
363392

364-
imgui_src += 'src/imgui/imgui_impl_glfm_gles3.cpp'
393+
imgui_src += 'src/imgui/imgui_impl_glfm.cpp'
394+
imgui_src += 'src/imgui/imgui_impl_opengl3.cpp'
365395

366396
executable('glimpse_viewer',
367397
[ 'src/glimpse_viewer.cc', 'src/ios_utils.m' ] + client_api_src + imgui_src,
@@ -379,14 +409,24 @@ if platform_ios == true
379409
])
380410
endif
381411

382-
if not meson.is_cross_build()
412+
if (
413+
#host_machine.system() == 'windows' or
414+
host_machine.system() == 'linux' or
415+
(host_machine.system() == 'darwin' and platform_ios == false))
416+
is_development_platform = true
417+
else
418+
is_development_platform = false
419+
endif
420+
421+
if is_development_platform
383422

384423
executable('image-pre-processor',
385424
[ 'src/image-pre-processor.cc',
386425
'src/tinyexr.cc',
387426
'src/parson.c',
388427
'src/perlin.c',
389428
'src/glimpse_log.c',
429+
'src/glimpse_mutex.c',
390430
'src/glimpse_properties.cc',
391431
'src/glimpse_data.cc',
392432
'src/image_utils.cc',
@@ -399,22 +439,24 @@ executable('train_rdt',
399439
[ 'src/train_rdt.c',
400440
'src/glimpse_rdt.cc',
401441
'src/glimpse_log.c',
442+
'src/glimpse_mutex.c',
402443
'src/glimpse_properties.cc',
403444
'src/glimpse_data.cc',
404445
'src/image_utils.cc',
405446
'src/rdt_tree.cc',
406447
'src/tinyexr.cc',
407448
'src/parson.c',
408449
'src/llist.c',
409-
'src/xalloc.c',
410-
'src/pthread_barrier/pthread_barrier.c' ],
450+
'src/xalloc.c'
451+
],
411452
include_directories: inc,
412453
dependencies: [ libpng_dep, threads_dep ])
413454

414455
executable('test_rdt',
415456
[ 'src/test_rdt.cc',
416457
'src/glimpse_rdt.cc',
417458
'src/glimpse_log.c',
459+
'src/glimpse_mutex.c',
418460
'src/glimpse_properties.cc',
419461
'src/glimpse_data.cc',
420462
'src/image_utils.cc',
@@ -430,6 +472,7 @@ executable('test_rdt',
430472
executable('annotate_bone_map',
431473
[ 'src/annotate_bone_map.cc',
432474
'src/glimpse_log.c',
475+
'src/glimpse_mutex.c',
433476
'src/glimpse_data.cc',
434477
'src/image_utils.cc',
435478
'src/tinyexr.cc',
@@ -442,6 +485,7 @@ executable('annotate_bone_map',
442485
executable('train_joint_params',
443486
[ 'src/train_joint_params.cc',
444487
'src/glimpse_log.c',
488+
'src/glimpse_mutex.c',
445489
'src/glimpse_data.cc',
446490
'src/infer_labels.cc',
447491
'src/joints_inferrer.cc',
@@ -458,6 +502,7 @@ executable('train_joint_params',
458502
executable('depth2labels',
459503
[ 'src/depth2labels.cc',
460504
'src/glimpse_log.c',
505+
'src/glimpse_mutex.c',
461506
'src/infer_labels.cc',
462507
'src/image_utils.cc',
463508
'src/rdt_tree.cc',
@@ -483,22 +528,16 @@ executable('pfm-to-exr',
483528
'src/tinyexr.cc' ],
484529
include_directories: inc)
485530

486-
executable('json-to-rdt',
487-
[ 'src/json-to-rdt.c',
488-
'src/glimpse_log.c',
489-
'src/rdt_tree.cc',
490-
'src/parson.c',
491-
'src/xalloc.c' ],
492-
include_directories: inc)
493-
494531
executable('jip-to-json',
495532
[ 'src/jip-to-json.c',
496533
'src/glimpse_log.c',
534+
'src/glimpse_mutex.c',
497535
'src/jip.cc',
498536
'src/parson.c',
499537
'src/llist.c',
500538
'src/xalloc.c' ],
501-
include_directories: inc)
539+
include_directories: inc,
540+
dependencies: [ threads_dep ])
502541

503542
executable('pfm-debug',
504543
[ 'src/pfm-debug.c' ],
@@ -507,6 +546,7 @@ executable('pfm-debug',
507546
executable('index-to-recording',
508547
[ 'src/index-to-recording.cc',
509548
'src/glimpse_log.c',
549+
'src/glimpse_mutex.c',
510550
'src/glimpse_data.cc',
511551
'src/image_utils.cc',
512552
'src/rdt_tree.cc',
@@ -529,19 +569,35 @@ if snappy_dep.found()
529569
dependencies: [ snappy_dep, libpng_dep, threads_dep ])
530570
endif
531571

572+
endif # is_development_platform
573+
574+
executable('json-to-rdt',
575+
[ 'src/json-to-rdt.c',
576+
'src/glimpse_log.c',
577+
'src/glimpse_mutex.c',
578+
'src/rdt_tree.cc',
579+
'src/parson.c',
580+
'src/xalloc.c' ] + getopt_src,
581+
include_directories: inc,
582+
dependencies: [ threads_dep ])
583+
584+
532585
if glfw_dep.found() and epoxy_dep.found()
533-
viewer_defines = client_api_defines + [ '-DUSE_GLFW' ]
534-
imgui_src += 'src/imgui/imgui_impl_glfw_gles3.cpp'
586+
viewer_defines = client_api_defines + [
587+
'-DUSE_GLFW',
588+
'-DGLFW_INCLUDE_NONE',
589+
'-DIMGUI_IMPL_OPENGL_LOADER_CUSTOM=<epoxy/gl.h>'
590+
]
591+
imgui_src += 'src/imgui/imgui_impl_glfw.cpp'
592+
imgui_src += 'src/imgui/imgui_impl_opengl3.cpp'
535593
executable('glimpse_viewer',
536-
[ 'src/glimpse_viewer.cc' ] + client_api_src + imgui_src,
594+
[ 'src/glimpse_viewer.cc' ] + client_api_src + imgui_src + getopt_src,
537595
include_directories: inc,
538596
dependencies: client_api_deps + [ glfw_dep ],
539597
c_args: viewer_defines,
540598
cpp_args: viewer_defines)
541599
endif
542600

543-
endif # is_cross_build
544-
545601
if unity_enabled
546602
install_args = [
547603
'--buildtype', get_option('buildtype'),

src/annotate_bone_map.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@
2828
#include <string.h>
2929
#include <thread>
3030
#include <pthread.h>
31-
#include <getopt.h>
31+
32+
#include <getopt-compat.h>
3233

3334
#include <cmath>
3435
#include <queue>

src/basename-compat.c

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
/*
2+
* Copyright (C) 2018 Robert Bragg <[email protected]>
3+
*
4+
* Permission is hereby granted, free of charge, to any person
5+
* obtaining a copy of this software and associated documentation
6+
* files (the "Software"), to deal in the Software without
7+
* restriction, including without limitation the rights to use, copy,
8+
* modify, merge, publish, distribute, sublicense, and/or sell copies
9+
* of the Software, and to permit persons to whom the Software is
10+
* furnished to do so, subject to the following conditions:
11+
*
12+
* The above copyright notice and this permission notice shall be
13+
* included in all copies or substantial portions of the Software.
14+
*
15+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16+
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17+
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18+
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
19+
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
20+
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21+
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22+
* SOFTWARE.
23+
*/
24+
25+
#include "basename-compat.h"
26+
27+
#ifdef _WIN32
28+
29+
#include <stdlib.h>
30+
31+
char *
32+
basename(char *filename)
33+
{
34+
int len = strlen(filename);
35+
36+
char *fname = alloca(len + 1);
37+
char *ext = alloca(len + 1);
38+
39+
_splitpath_s(filename,
40+
NULL, /* drive */
41+
0,
42+
NULL, /* dir */
43+
0,
44+
fname, /* base name (no ext) */
45+
len + 1,
46+
ext,
47+
len + 1);
48+
snprintf(filename, len + 1, "%s%s", fname, ext);
49+
50+
return filename;
51+
}
52+
53+
char *
54+
dirname(char *filename)
55+
{
56+
int len = strlen(filename);
57+
58+
char *drive = alloca(len + 1);
59+
char *dir = alloca(len + 1);
60+
61+
_splitpath_s(filename,
62+
drive, /* drive */
63+
len + 1,
64+
dir, /* dir */
65+
len + 1,
66+
NULL, /* base name (no ext) */
67+
0,
68+
NULL,
69+
0);
70+
snprintf(filename, len + 1, "%s/%s", drive, dir);
71+
72+
return filename;
73+
}
74+
75+
#endif

src/basename-compat.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#pragma once
2+
3+
#ifndef _WIN32
4+
#include <libgen.h>
5+
#else
6+
7+
#ifdef __cplusplus
8+
extern "C" {
9+
#endif
10+
char *basename(char *path);
11+
char *dirname(char *path);
12+
#ifdef __cplusplus
13+
}
14+
#endif
15+
16+
#endif

src/depth2labels.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@
3030
#include <stdio.h>
3131
#include <string.h>
3232
#include <math.h>
33-
#include <getopt.h>
33+
34+
#include <getopt-compat.h>
3435

3536
#include <cmath>
3637
#include <vector>

0 commit comments

Comments
 (0)