-
Notifications
You must be signed in to change notification settings - Fork 0
/
prepare-build.bat
193 lines (156 loc) · 4.02 KB
/
prepare-build.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
@echo off
setlocal ENABLEEXTENSIONS ENABLEDELAYEDEXPANSION
::
:: Toolchain selection
::
echo.
echo Select toolchain:
echo 1^) MinGW Makefiles
echo 2^) Eclipse + MinGW Makefiles
echo 3^) Visual Studio 10 ^(2010^)
echo 4^) Visual Studio 11 ^(2012^)
echo 5^) Visual Studio 12 ^(2013^)
echo 6^) Visual Studio 14 ^(2015^)
choice /c 123456 /n /m ">"
set TOOLCHAIN=%ERRORLEVEL%
if "%TOOLCHAIN%" == "1" (
set CMAKE_GEN="MinGW Makefiles"
set BUILD_DIR="MinGW"
) else if "%TOOLCHAIN%" == "2" (
set CMAKE_GEN="Eclipse CDT4 - MinGW Makefiles"
set BUILD_DIR="Eclipse-MinGW"
) else if "%TOOLCHAIN%" == "3" (
set CMAKE_GEN="Visual Studio 10"
set BUILD_DIR="VS10"
) else if "%TOOLCHAIN%" == "4" (
set CMAKE_GEN="Visual Studio 11"
set BUILD_DIR="VS11"
) else if "%TOOLCHAIN%" == "5" (
set CMAKE_GEN="Visual Studio 12"
set BUILD_DIR="VS12"
) else if "%TOOLCHAIN%" == "6" (
set CMAKE_GEN="Visual Studio 14"
set BUILD_DIR="VS14"
) else (
echo ERROR: Invalid toolchain!
exit /b 1
)
if %TOOLCHAIN% leq 2 (
set CMAKE_OPTS=!CMAKE_OPTS! -DCMAKE_CXX_COMPILER_ARG1=-std=c++11
)
::
:: Build type selection
::
echo.
echo Select build type:
echo 1^) Shared library ^(DLL^)
echo 2^) Static library
choice /c 12 /n /m ">"
set LIBRARY_TYPE=%ERRORLEVEL%
if "%LIBRARY_TYPE%" == "1" (
set BUILD_DIR_EXT="dll"
set CMAKE_OPTS=!CMAKE_OPTS! -DBUILD_SHARED_LIBS=YES
) else if "%LIBRARY_TYPE%" == "2" (
set BUILD_DIR_EXT="static"
set CMAKE_OPTS=!CMAKE_OPTS! -DBUILD_SHARED_LIBS=NO
) else (
echo ERROR: Invalid build type!
exit /b 1
)
::
:: Release type selection
::
echo.
echo Select release type:
echo 1^) Release
echo 2^) Debug
if %TOOLCHAIN% leq 2 (
echo 3^) Coverage
choice /c 123 /n /m ">"
set RELEASE_TYPE=!ERRORLEVEL!
) else (
choice /c 12 /n /m ">"
set RELEASE_TYPE=!ERRORLEVEL!
)
if "%RELEASE_TYPE%" == "1" (
set CMAKE_OPTS=!CMAKE_OPTS! -DCOVERAGE=OFF -DCMAKE_BUILD_TYPE=Release
set BUILD_DIR_EXT=Release_!BUILD_DIR_EXT!
) else if "%RELEASE_TYPE%" == "2" (
set CMAKE_OPTS=!CMAKE_OPTS! -DCOVERAGE=OFF -DCMAKE_BUILD_TYPE=Debug
set BUILD_DIR_EXT=Debug_!BUILD_DIR_EXT!
) else if "%RELEASE_TYPE%" == "3" (
set CMAKE_OPTS=!CMAKE_OPTS! -DCOVERAGE=ON -DCMAKE_BUILD_TYPE=Coverage
set BUILD_DIR_EXT=Coverage_!BUILD_DIR_EXT!
) else (
echo ERROR: Invalid release type!
exit /b 1
)
::
:: Eclipse source project generation selection
::
if "%TOOLCHAIN%" == "2" (
echo.
echo Generate Eclipse source project?
echo 1^) Yes
echo 2^) No
choice /c 12 /n /m ">"
set ECLIPSE_SRC_PRJ=!ERRORLEVEL!
if "!ECLIPSE_SRC_PRJ!" == "1" (
set CMAKE_OPTS=!CMAKE_OPTS! -DCMAKE_ECLIPSE_GENERATE_SOURCE_PROJECT=YES
) else (
set CMAKE_OPTS=!CMAKE_OPTS! -DCMAKE_ECLIPSE_GENERATE_SOURCE_PROJECT=NO
)
)
::
:: Documentation generation selection
::
echo.
echo Generate documentation?
echo 1^) Yes
echo 2^) No
choice /c 12 /n /m ">"
set GENERATE_DOC=%ERRORLEVEL%
if "%GENERATE_DOC%" == "1" (
echo.
echo Generate PDF documentation?
echo 1^) Yes
echo 2^) No
choice /c 12 /n /m ">"
set GENERATE_PDF=!ERRORLEVEL!
if "!GENERATE_PDF!" == "1" (
set CMAKE_OPTS=!CMAKE_OPTS! -DPDF_DOCS=ON
) else (
set CMAKE_OPTS=!CMAKE_OPTS! -DPDF_DOCS=OFF
)
echo.
echo Generate CHM documentation?
echo 1^) Yes
echo 2^) No
choice /c 12 /n /m ">"
set GENERATE_CHM=!ERRORLEVEL!
if "!GENERATE_CHM!" == "1" (
set CMAKE_OPTS=!CMAKE_OPTS! -DCHM_DOCS=ON
) else (
set CMAKE_OPTS=!CMAKE_OPTS! -DCHM_DOCS=OFF
)
echo.
echo Generate HTML documentation?
echo 1^) Yes
echo 2^) No
choice /c 12 /n /m ">"
set GENERATE_HTML=!ERRORLEVEL!
if "!GENERATE_HTML!" == "1" (
set CMAKE_OPTS=!CMAKE_OPTS! -DHTML_DOCS=ON
) else (
set CMAKE_OPTS=!CMAKE_OPTS! -DHTML_DOCS=OFF
)
)
::
:: Create directory and execute cmake
::
set BUILD_DIR=build_%BUILD_DIR%_%BUILD_DIR_EXT%
echo.
md %BUILD_DIR% 2>NUL
cd %BUILD_DIR%
cmake .. -G %CMAKE_GEN% -Wno-dev %CMAKE_OPTS%
pause