-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall-cmake.sh
executable file
·94 lines (76 loc) · 1.66 KB
/
install-cmake.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
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
#!/bin/bash
set -e
# https://github.com/Kitware/CMake/releases/download/v3.14.5/cmake-3.14.5.tar.gz
VERSION=""
BASE_URL="https://github.com/Kitware/CMake/releases/download"
source log.sh
START_TIME=$(get_now)
function usage() {
cat <<EOF
Usage: $(basename $0) [options]
OPTIONS:
-V, --version <version> Specify which version of LLVM to install.
-h, --help Display this help information.
Examples:
$(basename $0) -V 3.14.5
EOF
exit 0
}
while [ $# -gt 0 ]
do
case "$1" in
-V|--version)
shift
VERSION=$1
;;
-h|--help)
usage
;;
*)
error "Unknown option: $1"
usage
exit 2
;;
esac
shift
done
if [ "$VERSION"x = ""x ] ; then
error "Please specify CMake version"
usage
exit 2
fi
BASE_URL="${BASE_URL}/v${VERSION}"
SRC_DIR="cmake-${VERSION}"
SRC_TAR="${SRC_DIR}.tar.gz"
function download() {
info "Download $1"
wget "${BASE_URL}/$1"
}
function unzip() {
# Sanity check
if [ ! -f $1 ] ; then
error "File not found: $1"
exit 2
fi
info "Unzip $1"
tar -xzvf $1
}
function main() {
# Download source codes
info "Start downloading source codes ..."
download $SRC_TAR # LLVM
# Unzip source codes
info "Start unzipping files ..."
unzip $SRC_TAR
# Build
info "Start building ..."
cd $SRC_DIR
./bootstrap --system-curl && make -j6 && sudo make install
success "Finish building & installing!"
# Clean up workspace
info "Clean up the workspace ..."
cd ..
rm -rf $SRC_DIR $SRC_TAR
info "Done!"
}
main