forked from matus-chochlik/oglplus
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure.bat
343 lines (290 loc) · 8.93 KB
/
configure.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
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
@echo off
:: Copyright 2010-2015 Matus Chochlik. Distributed under the Boost
:: Software License, Version 1.0. (See accompanying file
:: LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
:: First, reset the variables we are using
CALL :reset_environment
:: Path to the build directory
SET OGLPLUS_BUILD_DIR=_build
::
:: Use the environment variables if they are set
IF DEFINED OGLPLUS_DEP_INCLUDE_DIRS (
SET "OGLPLUS_HEADER_SEARCH_PATHS=%OGLPLUS_DEP_INCLUDE_DIRS%"
)
IF DEFINED OGLPLUS_DEP_LIBRARY_DIRS (
SET "OGLPLUS_LIBRARY_SEARCH_PATHS=%OGLPLUS_DEP_LIBRARY_DIRS%"
)
::
:: Parse the command line arguments
::
:parse_cmd_line_args
::
:: If there are no (more) arguments finish the parsing loop
::
IF [%1] == [] GOTO :done_parsing_cmd_line
::
:: Print help and quit if /? /h --help is passed as argument
::
IF "%~1" == "/h" CALL :print_usage && GOTO :eof
IF "%~1" == "/?" CALL :print_usage && GOTO :eof
IF "%~1" == "--help" CALL :print_usage && GOTO :eof
::
:: Set OGLPLUS_NO_BOOST_CONFIG if we don't want to use Boost.Config
::
IF "%~1" == "--no-boost-config" (
SET /A OGLPLUS_NO_BOOST_CONFIG=1
GOTO :shift_cmd_line_args
)
::
:: Set OGLPLUS_NO_DOCS if we don't want to build docs
::
IF "%~1" == "--no-docs" (
SET /A OGLPLUS_NO_DOCS=1
GOTO :shift_cmd_line_args
)
::
:: Set OGLPLUS_NO_EXAMPLES if we don't want to build examples
::
IF "%~1" == "--no-examples" (
SET /A OGLPLUS_NO_EXAMPLES=1
GOTO :shift_cmd_line_args
)
::
:: Parse --prefix <path>
::
IF "%~1" == "--prefix" (
IF [%2] == [] ECHO Missing path after '--prefix' ! && EXIT /B 2
SET "OGLPLUS_PREFIX=%~2"
SHIFT
GOTO :shift_cmd_line_args
)
::
:: Parse --include-dir <path>
::
IF "%~1" == "--include-dir" (
IF [%2] == [] ECHO Missing path after '--include-dir' ! && EXIT /B 2
IF NOT EXIST %2 ECHO Path '%2' does not exist! && EXIT /B 3
IF DEFINED OGLPLUS_HEADER_SEARCH_PATHS (
SET "OGLPLUS_HEADER_SEARCH_PATHS=%OGLPLUS_HEADER_SEARCH_PATHS%;%~2"
) ELSE (SET "OGLPLUS_HEADER_SEARCH_PATHS=%~2")
SHIFT
GOTO :shift_cmd_line_args
)
::
:: Parse --library-dir <path>
::
IF "%~1" == "--library-dir" (
IF [%2] == [] ECHO Missing path after '--library-dir' ! && EXIT /B 2
IF NOT EXIST %2 ECHO Path '%2' does not exist! && EXIT /B 3
IF DEFINED OGLPLUS_LIBRARY_SEARCH_PATHS (
SET "OGLPLUS_LIBRARY_SEARCH_PATHS=%OGLPLUS_LIBRARY_SEARCH_PATHS%;%~2"
) ELSE (SET "OGLPLUS_LIBRARY_SEARCH_PATHS=%~2")
SHIFT
GOTO :shift_cmd_line_args
)
::
:: Parse --use-gl-api-lib <NAME>
::
IF "%~1" == "--use-gl-api-lib" (
IF [%2] == [] ECHO Missing name after '--use-gl-api-lib' ! && EXIT /B 2
SET "OGLPLUS_GL_API_LIB=%~2"
SHIFT
GOTO :shift_cmd_line_args
)
::
:: Parse --use-gl-init-lib <NAME>
::
IF "%~1" == "--use-gl-init-lib" (
IF [%2] == [] ECHO Missing name after '--use-gl-init-lib' ! && EXIT /B 2
SET "OGLPLUS_GL_INIT_LIB=%~2"
SHIFT
GOTO :shift_cmd_line_args
)
::
:: If the --from-scratch option was passed remove the build directory
::
IF "%~1" == "--from-scratch" (
IF EXIST %OGLPLUS_BUILD_DIR% (DEL /Q /F /S %OGLPLUS_BUILD_DIR%)
GOTO :shift_cmd_line_args
)
::
:: Set the cmake msvc generator
::
IF "%~1" == "--for-msvc" (
IF [%2] == [] ECHO Missing MSVC version after '--for-msvc' ! && EXIT /B 2
SET OGLPLUS_CMAKE_OPTIONS=%OGLPLUS_CMAKE_OPTIONS% -G "Visual Studio %~2"
SHIFT
GOTO :shift_cmd_line_args
)
::
:: If --cmake option is found gather the rest of the command line
::
IF "%~1" == "--cmake" (
SHIFT
GOTO :append_cmake_option
)
::
:: If we get here an invalid argument was supplied as argument
::
ECHO "Invalid command-line argument '%~1'"
EXIT /B 1
::
:: Shift the argument index and restart the parsing loop
::
:shift_cmd_line_args
SHIFT
GOTO :parse_cmd_line_args
::
:: Copy the rest of the arguments verbatim
:: to the OGLPLUS_CMAKE_OPTIONS variable
::
:append_cmake_option
IF [%1] == [] GOTO :done_parsing_cmd_line ELSE (
SET OGLPLUS_CMAKE_OPTIONS=%OGLPLUS_CMAKE_OPTIONS% %1
SHIFT
GOTO :append_cmake_option
)
::
:: We've finished parsing the command line arguments
::
:done_parsing_cmd_line
::
:: Begin building the cmake command line ..
::
SET OGLPLUS_CMAKE_COMMAND=cmake ..
::
:: .. append the verbatim cmake options if any ..
::
IF DEFINED OGLPLUS_CMAKE_OPTIONS (
SET OGLPLUS_CMAKE_COMMAND=%OGLPLUS_CMAKE_COMMAND% %OGLPLUS_CMAKE_OPTIONS%
)
::
:: .. set the installation prefix if any
::
IF DEFINED OGLPLUS_PREFIX (
SET OGLPLUS_CMAKE_COMMAND=%OGLPLUS_CMAKE_COMMAND% "-DCMAKE_INSTALL_PREFIX=%OGLPLUS_PREFIX%"
)
::
:: .. append the list of header file search paths ..
::
IF DEFINED OGLPLUS_HEADER_SEARCH_PATHS (
SET OGLPLUS_CMAKE_COMMAND=%OGLPLUS_CMAKE_COMMAND% "-DHEADER_SEARCH_PATHS=%OGLPLUS_HEADER_SEARCH_PATHS%"
)
::
:: .. append the list of library search paths ..
::
IF DEFINED OGLPLUS_LIBRARY_SEARCH_PATHS (
SET OGLPLUS_CMAKE_COMMAND=%OGLPLUS_CMAKE_COMMAND% "-DLIBRARY_SEARCH_PATHS=%OGLPLUS_LIBRARY_SEARCH_PATHS%"
)
::
:: .. append the forced api lib ..
::
IF DEFINED OGLPLUS_GL_API_LIB (
SET OGLPLUS_CMAKE_COMMAND=%OGLPLUS_CMAKE_COMMAND% "-DOGLPLUS_FORCE_GL_API_LIB=%OGLPLUS_GL_API_LIB%"
)
::
:: .. append the forced init lib ..
::
IF DEFINED OGLPLUS_GL_INIT_LIB (
SET OGLPLUS_CMAKE_COMMAND=%OGLPLUS_CMAKE_COMMAND% "-DOGLPLUS_FORCE_GL_INIT_LIB=%OGLPLUS_GL_INIT_LIB%"
)
::
:: .. define the OGLPLUS_NO_BOOST_CONFIG option ..
::
IF DEFINED OGLPLUS_NO_BOOST_CONFIG (
SET OGLPLUS_CMAKE_COMMAND=%OGLPLUS_CMAKE_COMMAND% "-DOGLPLUS_NO_BOOST_CONFIG=On"
)
::
:: .. define the OGLPLUS_NO_DOCS option ..
::
IF DEFINED OGLPLUS_NO_DOCS (
SET OGLPLUS_CMAKE_COMMAND=%OGLPLUS_CMAKE_COMMAND% "-DOGLPLUS_NO_DOCS=On"
)
::
:: .. define the OGLPLUS_NO_EXAMPLES option ..
::
IF DEFINED OGLPLUS_NO_EXAMPLES (
SET OGLPLUS_CMAKE_COMMAND=%OGLPLUS_CMAKE_COMMAND% "-DOGLPLUS_NO_EXAMPLES=On"
)
::
:: .. and make the build dir, go into it and invoke cmake
::
IF NOT EXIST %OGLPLUS_BUILD_DIR% (MD %OGLPLUS_BUILD_DIR%)
CD %OGLPLUS_BUILD_DIR% && %OGLPLUS_CMAKE_COMMAND% && CD ..
::
:: cleanup and quit
::
CALL :reset_environment
GOTO :eof
::
:: Resets the variables that this script defines
::
:reset_environment
SET OGLPLUS_HEADER_SEARCH_PATHS=
SET OGLPLUS_LIBRARY_SEARCH_PATHS=
SET OGLPLUS_BUILD_DIR=
SET OGLPLUS_CMAKE_COMMAND=
SET OGLPLUS_CMAKE_OPTIONS=
SET OGLPLUS_NO_BOOST_CONFIG=
SET OGLPLUS_NO_DOCS=
SET OGLPLUS_NO_EXAMPLES=
SET OGLPLUS_PREFIX=
GOTO :eof
::
:: Prints the usage screen
::
:print_usage
ECHO:configure: OGLplus cmake configuration script
ECHO.
ECHO:NOTE: Consider using the configure.py Python script if possible.
ECHO: configure.py is more versatile, robust and up to date.
ECHO: Run `configure.py --help' to display full help screen.
ECHO.
ECHO:Synopsis
ECHO:configure.bat [config-options] [^<--cmake^> [cmake-options]]
ECHO.
ECHO:All options after '-' or '--cmake' are passed verbatim to cmake
ECHO.
ECHO:config-options:
ECHO.
ECHO: --help ^| /h ^| /?: Print this help screen.
ECHO.
ECHO: --prefix PREFIX: Specifies the installation prefix. The path
ECHO: must be absolute or relative to the current
ECHO: working directory from which configure is
ECHO: invoked.
ECHO.
ECHO: --include-dir PATH: Specifies additional directory to search
ECHO: when looking for external headers like
ECHO: GL/glew.h or GL3/gl3.h. The specified path
ECHO: must be absolute or relative to the current
ECHO: working directory from which configure is
ECHO: invoked.
ECHO: This option may be specified multiple times
ECHO: to add multiple directories to the search list.
ECHO.
ECHO: --library-dir PATH: Specifies additional directory to search
ECHO: when looking for compiled libraries like
ECHO: GL, GLEW, glut, png, etc. The specified path
ECHO: must be absolute or relative to the current
ECHO: working directory from which configure is
ECHO: invoked.
ECHO: This option may be specified multiple times
ECHO: to add multiple directories to the search list.
ECHO.
ECHO: --for-msvc VERSION: Equivalent to --cmake -G "Visual Studio VERSION":
ECHO: Uses the cmake generator for Microsoft Visual studio
ECHO: with the specified VERSION.
ECHO.
ECHO: --cmake [options]: Everything following the --cmake option will
ECHO: be passed to cmake verbatim.
ECHO.
ECHO: --from-scratch Remove any previous cached and intermediate files
ECHO: and run the configuration process from scratch.
ECHO.
ECHO: --no-examples Do not build the examples and the textures.
ECHO.
ECHO: --no-docs Do not build and install the documentation.
ECHO.
CALL :reset_environment
GOTO :eof