-
Notifications
You must be signed in to change notification settings - Fork 0
/
new_cpp.sh
executable file
·64 lines (50 loc) · 1.15 KB
/
new_cpp.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
#!/bin/bash
# Load config for different machine setup.
source cpp/.experiment_config
# Define default options.
USE_BOOST=false
usage() {
echo "usage: new_cpp [options] project_name"
exit 0
}
# Parse options.
while test $# -gt 0; do
case "$1" in
-h|--help)
usage
;;
--use-boost)
USE_BOOST=true
shift
;;
--boost-version)
shift
BOOST_VERSION="$1"
shift
;;
*)
PROJECT_NAME=$1
break;
;;
esac
done
if [[ -z "$PROJECT_NAME" ]] ; then usage
fi
# Create project, generate makefiles and build.
echo "Creating project:" $PROJECT_NAME
if [ ! -d ./projects/cpp ]; then
mkdir -p ./projects/cpp
fi
pushd ./projects/cpp
mkdir $PROJECT_NAME
cp ../../templates/cpp/* $PROJECT_NAME
pushd $PROJECT_NAME
if $USE_BOOST ; then
echo "Using Boost version: $BOOST_VERSION"
CMAKE_ARGUMENTS="$CMAKE_ARGUMENTS -DUSE_BOOST=ON -DBOOST_PATH=$BOOST_PATH/$BOOST_VERSION/"
else
CMAKE_ARGUMENTS="$CMAKE_ARGUMENTS"
fi
echo "CMAKE_ARGUMENTS: $CMAKE_ARGUMENTS"
cmake $CMAKE_ARGUMENTS .
make