-
Notifications
You must be signed in to change notification settings - Fork 1
/
cmake_launch.sh
executable file
·85 lines (74 loc) · 1.25 KB
/
cmake_launch.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
#!/bin/bash
usage() {
cat << EOF
usage: `basename $0` [options]
This script set the appropriate compiler envinonment for CMake, and launches cmake in it.
OPTIONS:
-h Show this message
-g Prepare environment for GCC toolchain.
-l Prepare environment for CLANG toolchain
-p Path to CMakeLists.txt
EOF
}
CC=
CXX=
LD=/usr/bin/ld
CMAKEPATH=.
GCC=
CLANG=
CLEAN=
while getopts ":p:hglc" opt; do
case $opt in
g)
CC=/usr/bin/llvm-gcc
CXX=/usr/bin/llvm-g++
GCC=1
;;
l)
CC=
CXX=
CLANG=1
;;
p)
CMAKEPATH=$OPTARG
;;
c)
CLEAN=1
;;
h)
usage
exit 0
;;
\?)
usage
exit 1
;;
esac
done
if [[ $(uname) -ne "Darwin" ]]; then
echo "This script is meant for OS X. You do not need to run it on linux."
exit 0
fi
if [[ $GCC -eq 1 && $CLANG -eq 1 ]];
then
usage
exit 1
fi
echo "Exporting compiler environment variables..."
export CC=$CC
export CXX=$CXX
export LD=$LD
cd $CMAKEPATH
if [[ ! -z $CLEAN ]];
then
echo "Cleaning existing cmake residue..."
for dir in $(find . -type d -name "CMakeFiles");
do
rm -rf $dir 2>/dev/null
done
for cache in $(find . -type f -name "CMakeCache.txt");
do
rm $cache 2>/dev/null
done
fi
cmake .