forked from analogdevicesinc/ToF
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup_project.bat
300 lines (278 loc) · 7.37 KB
/
setup_project.bat
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
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
@ECHO off
SETLOCAL
::this script downloads and installs the dependencies (glog, protobuf and websockets) and builds the sdk.
::global variables
for %%F in (cd %0 ..) do set source_dir=%%~dpF
set /a display_help=0
set /a answer_yes=0
set /a set_build=0
set /a set_deps=0
set /a set_deps_install=0
set /a threads=4
set build_dire=""
set deps_dir=""
set deps_install_dir=""
set generator=""
set config_type=""
set generator=""
set /a set_config=0
set /a set_generator=0
::interpret the arguments
:interpret_arg
if "%1" neq "" (
if /I "%1" EQU "-h" (
set /a display_help=1
shift
goto :interpret_arg
)
if /I "%1" EQU "--help" (
set /a display_help=1
shift
goto :interpret_arg
)
if /I "%1" EQU "-y" (
set /a answer_yes=1
shift
goto :interpret_arg
)
if /I "%1" EQU "--yes" (
set /a answer_yes=1
shift
goto :interpret_arg
)
if /I "%1" EQU "-b" (
set build_dire=%2
set /a set_build=1
shift
shift
goto :interpret_arg
)
if /I "%1" EQU "--buildir" (
set build_dire=%2
set /a set_build=1
shift
shift
goto :interpret_arg
)
if /I "%1" EQU "-d" (
set deps_dir=%2
set /a set_deps=1
shift
shift
goto :interpret_arg
)
if /I "%1" EQU "--depsdir" (
set deps_dir=%2
set /a set_deps=1
shift
shift
goto :interpret_arg
)
if /I "%1" EQU "-i" (
set deps_install_dir=%2
set /a set_deps_install=1
shift
shift
goto :interpret_arg
)
if /I "%1" EQU "--depsinstalldir" (
set deps_install_dir=%2
set /a set_deps_install=1
shift
shift
goto :interpret_arg
)
if /I "%1" EQU "-g" (
set generator=%2
set /a set_generator=1
shift
shift
goto :interpret_arg
)
if /I "%1" EQU "--generator" (
set generator=%2
set /a set_generator=1
shift
shift
goto :interpret_arg
)
if /I "%1" EQU "-c" (
set config_type=%2
set /a set_config=1
shift
shift
goto :interpret_arg
)
if /I "%1" EQU "--configuration" (
set config_type=%2
set /a set_config=1
shift
shift
goto :interpret_arg
)
if /I "%1" EQU "-j" (
set threads=%2
shift
shift
goto :interpret_arg
)
shift
goto :interpret_arg
)
if %display_help%==1 (
call :print_help
EXIT /B 0
)
::check if the configuration is correct
set /a opt=0
if "%config_type%"=="Release" (
set /a opt=1
)
if "%config_type%"=="Debug" (
set /a opt=1
)
if %set_config%==0 (
set /a opt=1
set config_type=Release
)
if %opt%==0 (
echo Please enter a correct configuration (Release or Debug^)
EXIT /B %ERRORLEVEL%
)
echo Setup will continue with the configuration: %config_type%
::check if the generator is correct
set /a opt=0
set opencv_vs=15
if %generator%=="Visual Studio 17 2022" (
set /a opt=1
set opencv_vs=15
)
if %generator%=="Visual Studio 16 2019" (
set /a opt=1
set opencv_vs=15
)
if %generator%=="Visual Studio 15 2017 Win64" (
set /a opt=1
set opencv_vs=15
)
if %generator%=="Visual Studio 14 2015 Win64" (
set /a opt=1
set opencv_vs=14
)
if %set_generator%==0 (
set /a opt=1
set generator="Visual Studio 16 2019"
set opencv_vs=16
)
if %opt%==0 (
echo Please enter a correct configuration ("Visual Studio 17 2022";"Visual Studio 16 2019"; "Visual Studio 15 2017 Win64" or "Visual Studio 14 2015 Win64"^)
EXIT /B %ERRORLEVEL%
)
echo Setup will continue with the generator: %generator%
::set the diretories
if %set_build%==0 (
set build_dire=%CD%\build
)
echo The sdk will be built in: %build_dire%
if %set_deps%==0 (
set deps_dir=%CD%\deps
)
echo The deps will be downloaded in: %deps_dir%
if %set_deps_install%==0 (
set deps_install_dir=%deps_dir%\installed
)
echo The deps will be installed in: %deps_install_dir%
::ask for permission to continue the setup
if %answer_yes%==0 (
call :yes_or_exit "Do you want to continue?"
)
::create the missing folders
if not exist %build_dire% md %build_dire%
if not exist %deps_dir% md %deps_dir%
if not exist %deps_install_dir% md %deps_install_dir%
pushd %deps_install_dir%
set deps_install_dir=%CD%
popd
::call functions that install the dependencies
CALL :install_glog %config_type% %generator%
CALL :install_protobuf %config_type% %generator%
CALL :install_websockets %config_type% %generator%
::build the project with the selected options
pushd %build_dire%
cmake -G %generator% -DWITH_PYTHON=on -DCMAKE_PREFIX_PATH="%deps_install_dir%\glog;%deps_install_dir%\protobuf;%deps_install_dir%\libwebsockets" %source_dir% -DCMAKE_BUILD_TYPE=%config_type%
cmake --build . --config %config_type% -j %threads%
popd
EXIT /B %ERRORLEVEL%
:print_help
ECHO setup.bat [OPTIONS]
ECHO -h^|--help
ECHO Print a usage message briefly summarizing the command line options available, then exit.
ECHO -y^|--yes
ECHO Automatic yes to prompts.
ECHO -b^|--buildir
ECHO Specify the build directory of the SDK.
ECHO -d^|--depsdir
ECHO Specify the directory where the dependencies will be downloaded.
ECHO -i^|--depsinstalldir
ECHO Specify the directory where the dependencies will be installed.
ECHO -g^|--generator
ECHO Visual Studio 16 2019 = Generates Visual Studio 2019 project files.
ECHO Visual Studio 15 2017 Win64 = Generates Visual Studio 2017 project files.
ECHO Visual Studio 14 2015 Win64 = Generates Visual Studio 2015 project files.
ECHO -c^|--configuration
ECHO Release = Configuration for Release build.
ECHO Debug = Configuration for Debug build.
ECHO -j
ECHO Set the number of threads used for building, by default is set to 4.
EXIT /B 0
:yes_or_exit
:choice
set /P c="%~1 [Y/N]"
if /I "%c%" EQU "Y" goto :end_yes_or_exit
if /I "%c%" EQU "N" EXIT
goto :choice
:end_yes_or_exit
EXIT /B 0
:install_glog
set configuration=%~1
echo "Installing glog with config=%configuration% and generator=%generator%"
pushd %deps_dir%
if not exist "glog" ( git clone --branch v0.6.0 --depth 1 https://github.com/google/glog )
pushd glog
git checkout tags/v0.6.0
if not exist "build_0_6_0" ( mkdir build_0_6_0 )
pushd build_0_6_0
cmake -DWITH_GFLAGS=off -DCMAKE_INSTALL_PREFIX=%deps_install_dir%\glog -G %generator% ..
cmake --build . --target install --config %configuration% -j %threads%
popd
popd
popd
EXIT /B 0
:install_protobuf
set configuration=%~1
echo "Installing protobuf with config=%configuration% and generator=%generator%"
pushd %deps_dir%
if not exist "protobuf" ( git clone --branch v3.9.0 --depth 1 https://github.com/protocolbuffers/protobuf )
pushd protobuf
if not exist "build_3_9_0" ( mkdir build_3_9_0 )
pushd build_3_9_0
cmake -Dprotobuf_BUILD_TESTS=OFF -DCMAKE_INSTALL_PREFIX=%deps_install_dir%\protobuf -Dprotobuf_MSVC_STATIC_RUNTIME=OFF -G %generator% ..\cmake\
cmake --build . --target install --config %configuration% -j %threads%
popd
popd
popd
EXIT /B 0
:install_websockets
set configuration=%~1
echo "Installing websockets with config=%configuration% and generator=%generator%"
pushd %deps_dir%
if not exist "libwebsockets" ( git clone --branch v3.1-stable --depth 1 https://libwebsockets.org/repo/libwebsockets )
pushd libwebsockets
if not exist "build_3_1_stable" ( mkdir build_3_1_stable )
pushd build_3_1_stable
cmake -DLWS_WITH_SSL=OFF -DLWS_WITHOUT_TESTAPPS=ON -DLWS_WITHOUT_TEST_SERVER=ON -DLWS_WITH_SHARED=ON -DLWS_WITH_STATIC=OFF -DCMAKE_INSTALL_PREFIX=%deps_install_dir%\libwebsockets -G %generator% ..
cmake --build . --target install --config %configuration% -j %threads%
popd
popd
popd
EXIT /B 0