forked from romange/helio
-
Notifications
You must be signed in to change notification settings - Fork 0
/
blaze.sh
executable file
·64 lines (57 loc) · 1.23 KB
/
blaze.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
61
62
63
64
#!/usr/bin/env bash
TARGET_BUILD_TYPE=Debug
BUILD_PREF=build
BUILD_SUF=dbg
COMPILER='g++'
GENERATOR='-GNinja'
LAUNCHER=$(command -v ccache)
if [ -x $LAUNCHER ]; then
echo "Using launcher $LAUNCHER"
LAUNCHER="-DCMAKE_CXX_COMPILER_LAUNCHER=$LAUNCHER"
else
LAUNCHER=''
fi
for ((i=1;i <= $#;));do
ARG=${!i}
case "$ARG" in
-release)
TARGET_BUILD_TYPE=Release
BUILD_SUF=opt
shift
;;
-clang)
COMPILER=`which clang++`
BUILD_PREF=clang
shift
;;
-ninja)
GENERATOR='-GNinja'
shift
;;
-make)
GENERATOR=-G'Unix Makefiles'
shift
;;
-D*) # bypass flags
i=$((i + 1))
;;
*)
echo bad option "$ARG"
exit 1
;;
esac
done
BUILD_DIR=${BUILD_PREF}-${BUILD_SUF}
set -x
result="$(cmake --version | grep -Eo '[0-9]+\.[0-9]+\.[0-9]+')"
major="${result%%.*}"
remainder="${result#*.}"
minor="${remainder%.*}"
if [ "$major" -lt 3 ] ||
( [ "$major" -eq 3 ] &&
( [ "$minor" -lt 4 ] )) ; then
echo "you are using an older version of cmake, need cmake >= 3.4"
exit 1
fi
cmake -L -B $BUILD_DIR -DCMAKE_BUILD_TYPE=$TARGET_BUILD_TYPE -DCMAKE_CXX_COMPILER=$COMPILER \
"$GENERATOR" $LAUNCHER "$@"