forked from pelagos-consulting/HIP_Course
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
executable file
·51 lines (40 loc) · 1.02 KB
/
install.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
#!/bin/bash
# Get the location of this script
script_path=$(dirname "$0")
# This script will load any modules and get the environment ready
env_script=$(realpath $script_path/env)
source $env_script
# Make the directory to build in
build_dir=$COURSE_DIR/build
mkdir -p $build_dir
cd $build_dir
# Run cmake
cmake -DCMAKE_INSTALL_MESSAGE=NEVER -DCMAKE_VERBOSE_MAKEFILE=OFF -DCMAKE_RULE_MESSAGES=OFF -DCMAKE_INSTALL_PREFIX=$INSTALL_DIR -DCMAKE_BUILD_TYPE=$BUILD_TYPE $COURSE_DIR/
# Make everything and install
make -j$(nproc) all install
# Write a build script
build_script=${RUN_DIR}/build
cat << EOF > ${build_script}
#!/bin/bash --login
source ${env_script}
cd $build_dir
if [ "\$#" -eq 1 ]
then
make \$1 install
else
make all install
fi
EOF
# Change permissions
chmod u+x ${build_script}
# Write a run script
run_script=${RUN_DIR}/run
# Make a run script
cat << EOF > ${run_script}
#!/bin/bash --login
source ${env_script}
# Run all arguments passed to the script
\$@
EOF
# Change permissions
chmod u+x ${run_script}