-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathconfigure
executable file
·283 lines (256 loc) · 8.06 KB
/
configure
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
#!/usr/bin/env bash
make_cmake_list(){
if [ -e CMakeLists.txt ]; then
rm CMakeLists.txt
fi
if [ $1 = "*" ]; then
echo "No child folder found!"
echo "# Automaticaly created" >> CMakeLists.txt
else
echo "# Automaticaly created" >> CMakeLists.txt
for name in $*
do
if [ $name = "CMakeLists.txt" ]; then
echo "Skip CMakeLists.txt"
else
echo "Adding dir: " $name
echo -ne "add_subdirectory("$name")\r\n" >> CMakeLists.txt
fi
done
fi
}
print_usage(){
echo "Usage:"
echo -ne "\n./configure [-g|--generator GeneratorName] [-f|--folder FolderName] [-b|--build BuildType]"
echo -ne " [-p|--param ParamName] [-d|--documentation full/fast] [-h|--help]"
echo -ne " [-e|--external-dir ExternalDir] [-P|--cmake-param]"
echo -ne " [-t|--enable-testing] [--test-name name] [--test-site addr] [-c|--create-lists] [-]\n"
echo
echo -ne "Options:\n"
echo "[-b|--build BuildType]: The cmake build type release/debug/nolog/maintain - default release"
echo "[-e|--external-dir ExternalDir]: path to external libraries"
echo "[-f|--folder-name FolderName]: Specify the build folder name - default is the generator name or the build type if the generator was not specified"
echo "[--prefix] Install path prefix"
echo
echo "[-g|--generator GeneratorName]: Specify the cmake generator - default cmake's default"
echo "[-F|--folder-path FolderPath]: Specify the build folder path - unlike the build folder-name wich creates a folder under build, this flag allows creating a build folder anywhere"
echo "[-d|--documentation full/fast]: Build either fast or full documentation"
echo "[-c|--compile-options ParamName]: Extra compilation flags. E.g. -c \"-fsanitize=address -fno-omit-frame-pointer\""
echo "[-l|--link-options ParamName]: Extra link flags. E.g. -l \"-fsanitize=address\""
echo "[-P|--cmake-param]: Some parameters given to cmake like: -DECLIPSE_CDT4_GENERATE_SOURCE_PROJECT=TRUE; \"-DCMake_RUN_CLANG_TIDY:BOOLEAN=true\""
echo
echo "Examples:"
echo
echo "1) create simple make release build:"
echo "$ ./configure -e ~/work/external"
echo "$ cd build/release"
echo "$ make"
echo "$ sudo make install"
echo
echo "2) create debug build:"
echo "$ ./configure -b debug -e ~/work/external --prefix ~/work/external"
echo "$ cd build/debug"
echo "$ make install"
echo
echo "3) create a maintain build locate in \"./build/mnt\" with instalation prefix:"
echo "$ ./configure -f mnt -e ~/work/external -b maintain --prefix ~/work/install"
echo "$ cd build/mnt"
echo "$ make install"
echo
echo "4) create a maintain build with Address Sanitizer:"
echo "$ ./configure -b maintain -f asan -e ~/work/external -c \"-fsanitize=address -fno-omit-frame-pointer\" -l \"-fsanitize=address\""
echo "$ cd build/asan"
echo "$ make Experimental"
echo
echo "5) create a maintain build with Thread Sanitizer"
echo "$ ./configure -b maintain -f tsan -e ~/work/external -c \"-fsanitize=thread\" -l \"-fsanitize=thread\""
echo "$ cd build/asan"
echo "$ make Experimental"
echo
echo "6) create a debug build solution for Visual Studio17 2022 from Git Bash"
echo "./configure -b debug -f debug -e ../external_debug_x64/ -g \"Visual Studio 17 2022\" -A x64"
echo
echo "7) create a debug Ninja build for C++17"
echo "./configure -b debug -e ../external -f debug -g Ninja -P \"-DCMAKE_CXX_STANDARD=17\""
echo
echo "8) create release build with using std::shared_ptr for solid::frame::mprpc::Message"
echo "./configure -f release_sp -e ../external/ -g Ninja -P \"-DSOLID_MPRPC_USE_SHARED_PTR_MESSAGE=on\""
echo
exit
}
# if [ "$1" = "" ] ; then
# print_usage
# fi
# First define and initilaize the variables
GENERATOR=
#CMAKE_PARAM=()
DOCUMENTATION=
BUILD_TYPE=
FOLDER_NAME=
FOLDER_PATH=
HELP="no"
EXTERNAL_DIR=
CREATE_LISTS=
INSTALL_PREFIX=
EXTRA_COMPILE_OPTIONS=
EXTRA_LINK_OPTIONS=
ARCHITECTURE=
FORTIFY="OFF"
#echo "$@"
pass_arg_count=0
#while [ "$#" -gt 0 ]; do
while [ $# -gt $pass_arg_count ]
do
CURRENT_OPT="$1"
UNKNOWN_ARG=no
case "$1" in
-g|--generator)
shift
GENERATOR=$1
;;
-f|--folder-name)
shift
FOLDER_NAME=$1
;;
-F|--folder-path)
shift
FOLDER_PATH=$1
;;
-b|--build)
shift
BUILD_TYPE=$1
;;
-d|--documentation)
if [ -z "$2" ] || echo "$2" | grep '^-' >/dev/null 2>&1; then
DOCUMENTATION="fast"
else
shift;
DOCUMENTATION=$1
fi
;;
--prefix)
shift
INSTALL_PREFIX="$1"
;;
-P|--cmake-param)
shift
#CMAKE_PARAM=($CMAKE_PARAM "$1")
arg="$1"
set -- "$@" "$arg"
pass_arg_count=`expr $pass_arg_count + 1`
;;
-c|--compile-options)
shift
EXTRA_COMPILE_OPTIONS=$EXTRA_COMPILE_OPTIONS"$1 "
;;
-l|--link-options)
shift
EXTRA_LINK_OPTIONS=$EXTRA_LINK_OPTIONS"$1 "
;;
-e|--external-dir)
shift;
EXTERNAL_DIR=$1
;;
-A|--architecture)
shift;
ARCHITECTURE="$1"
;;
-c|--create-lists)
CREATE_LISTS="yes"
;;
-h|--help)
HELP="yes"
;;
--test-name)
shift
TEST_NAME="$1"
;;
--test-site)
shift
TEST_SITE="$1"
;;
--fortify)
FORTIFY="ON"
;;
*)
HELP="yes"
;;
esac
shift
done
if [ "$HELP" = "yes" ]; then
print_usage
exit
fi
if [ ! -z $EXTERNAL_DIR ]; then
if [ ! -d $EXTERNAL_DIR ]; then
echo "Invalid prerequisites path: $EXTERNAL_DIR"
exit
fi
cd $EXTERNAL_DIR
EXTERNAL_DIR=`pwd`
cd -
fi
echo "Using extern prerequisites from: $EXTERNAL_DIR"
if [ "$DOCUMENTATION" = "full" ]; then
echo "Building full documentation ..."
rm -rf documentation/html/
rm -rf documentation/latex/
doxygen documentation/Doxyfile
tar -cjf documentation/full.tar.bz2 documentation/html/ documentation/index.html
echo "Done building full documentation"
exit
fi
if [ "$DOCUMENTATION" = "fast" ]; then
echo "Building documentation..."
rm -rf documentation/html/
doxygen documentation/Doxyfile.fast
tar -cjf documentation/fast.tar.bz2 documentation/html/ documentation/index.html
echo "Done building documentation"
exit
fi
if [ "$BUILD_TYPE" = "" ]; then
BUILD_TYPE="release"
fi
if [ "$FOLDER_NAME" = "" ]; then
if [ "$GENERATOR" = "" ]; then
FOLDER_NAME=$BUILD_TYPE
else
FOLDER_NAME=$GENERATOR
fi
fi
echo "Configure an out-of-source build configuration of type [$BUILD_TYPE] on folder [build/$FOLDER_NAME] compile-options [$EXTRA_COMPILE_OPTIONS] link-options [$EXTRA_LINK_OPTIONS]"
SRC_PATH="`pwd`"
if [ "$FOLDER_PATH" = "" ]; then
if [ ! -d build ]; then
mkdir build
fi
mkdir "build/$FOLDER_NAME"
cd "build/$FOLDER_NAME"
else
echo "$FOLDER_PATH"
mkdir "$FOLDER_PATH"
cd "$FOLDER_PATH"
fi
echo $GENERATOR
echo "The list of parameters forwarded to cmake:"
for param in "$@"; do
echo "$param"
done
echo
echo -ne "./configure -f $FOLDER_NAME -F \"$FOLDER_PATH\" -b \"$BUILD_TYPE\" -g \"$GENERATOR\" -e \"$EXTERNAL_DIR\" \"$@\" \"$SRC_PATH\" \"$FORTIFY\" \r\n" > configure.txt
if [ "$GENERATOR" = "" ]; then
echo "Using cmake's default generator"
else
declare -a GEN=("-G" "$GENERATOR")
echo "Using cmake's $GENERATOR - ${GEN[@]}"
fi
if [ "$ARCHITECTURE" = "" ]; then
echo "Using default architecture"
else
declare -a ARC=("-A" "$ARCHITECTURE")
echo "Using architecture $ARCHITECTURE - ${ARC[@]}"
fi
exec cmake "${GEN[@]}" "${ARC[@]}" -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DEXTERNAL_DIR:PATH="$EXTERNAL_DIR" -DEXTRA_COMPILE_OPTIONS:STRING="$EXTRA_COMPILE_OPTIONS" -DEXTRA_LINK_OPTIONS:STRING="$EXTRA_LINK_OPTIONS" -DCMAKE_INSTALL_PREFIX="$INSTALL_PREFIX" -DFORTIFY:BOOL=$FORTIFY "$@" "$SRC_PATH"
echo "Done!"
exit