-
Notifications
You must be signed in to change notification settings - Fork 203
/
build.sh
executable file
·60 lines (52 loc) · 882 Bytes
/
build.sh
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
#!/bin/bash
main()
{
CC=gcc
CXX=g++
if [[ "$*" =~ "--help" ]]; then
help
exit 0;
fi
n=0
args=()
for i in "$@"
do
case $i in
-j=*|--jobs=*)
jobs="-j${i#*=}"
shift
;;
-c=*|--compiler=*)
C="${i#*=}"
shift
;;
*)
args[$n]="$i"
((++n))
;;
esac
done
case "$C" in
("intel"|"icc") CC=icc CXX=icpc ;;
("gcc"|"g++") CC=gcc CXX=g++ ;;
("clang|llvm") CC=clang CXX=clang++ ;;
*)
;;
esac
rm -rf build
mkdir build
pushd build &> /dev/null
CC=$CC CXX=$CXX cmake ${args[@]} ..
make ${jobs}
popd > /dev/null
}
help()
{
printf "Usage: ./build.sh <options>\n\n"
printf " -c= | --compiler=<icc|gcc|clang> - Select preferred C/C++ compiler to build\n"
printf " -j= | --jobs=<N> - Specifies the number of jobs (commands) to run simultaneously (For faster building)\n\n"
}
# Initialize
main $*
# Exit normally
exit 0