forked from KATRIN-Experiment/Kassiopeia
-
Notifications
You must be signed in to change notification settings - Fork 2
/
setup.sh
executable file
·92 lines (79 loc) · 2.91 KB
/
setup.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
#!/bin/bash
# Build and install the default configuration of Kassiopeia
#
# Usage:
# ./setup.sh
#
# Respects the following optional environment variables, with defaults:
# KASSIOPEIA_BUILD_TYPE=RelWithDebInfo
# KASSIOPEIA_INSTALL_PREFIX=install
# KASSIOPEIA_BUILD_PREFIX=build
# KASSIOPEIA_MAKECMD=make
# KASSIOPEIA_CUSTOM_CMAKE_ARGS=""
# KASSIOPEIA_GIT_BRANCH=""
# KASSIOPEIA_GIT_COMMIT=""
# KASSIOPEIA_CPUS=$(($(nproc)-1))
#
# Full command line examples:
# KASSIOPEIA_BUILD_TYPE="Release" ./setup.sh
# KASSIOPEIA_BUILD_TYPE="RelWithDebInfo" \
# KASSIOPEIA_INSTALL_PREFIX="/path/to/install" \
# KASSIOPEIA_BUILD_PREFIX="/path/to/build" \
# ./setup.sh
# KASSIOPEIA_BUILD_TYPE="RelWithDebInfo" \
# KASSIOPEIA_INSTALL_PREFIX="/path/to/install" \
# KASSIOPEIA_BUILD_PREFIX="/path/to/build" \
# KASSIOPEIA_MAKECMD="ninja" \
# KASSIOPEIA_CUSTOM_CMAKE_ARGS="-GNinja" \
# KASSIOPEIA_GIT_BRANCH="develop" \
# KASSIOPEIA_GIT_COMMIT="6c9dbbf3e" \
# KASSIOPEIA_CPUS=4 \
# ./setup.sh
if [ $# -ne 0 ] ; then
echo "Since 2023-07, setup.sh uses environment variables instead of arguments. Documentation can be found at the beginning of setup.sh."
exit -1
fi
KASSIOPEIA_BUILD_TYPE=${KASSIOPEIA_BUILD_TYPE:-"RelWithDebInfo"}
KASSIOPEIA_INSTALL_PREFIX=$(realpath -s ${KASSIOPEIA_INSTALL_PREFIX:-"install"})
KASSIOPEIA_BUILD_PREFIX=$(realpath -s ${KASSIOPEIA_BUILD_PREFIX:-"build"})
KASSIOPEIA_MAKECMD=${KASSIOPEIA_MAKECMD:-"make"}
KASSIOPEIA_CUSTOM_CMAKE_ARGS=${KASSIOPEIA_CUSTOM_CMAKE_ARGS:-""}
KASSIOPEIA_GIT_BRANCH=${KASSIOPEIA_GIT_BRANCH:-""}
KASSIOPEIA_GIT_COMMIT=${KASSIOPEIA_GIT_COMMIT:-""}
KASSIOPEIA_CPUS=${KASSIOPEIA_CPUS:-"$(($(nproc)-1))"}
echo "Building KASPER $KASSIOPEIA_BUILD_TYPE for '$KASSIOPEIA_INSTALL_PREFIX' in '$KASSIOPEIA_BUILD_PREFIX'"
# Cause script to exit after a command failed
set -e
GIT_ARGS="-DKASPER_GIT_INFO_USERDEFINED=OFF"
if [[ ! -z $KASSIOPEIA_GIT_BRANCH ]]
then
GIT_ARGS="-DKASPER_GIT_INFO_USERDEFINED=ON \
-DKASPER_GIT_BRANCH=$KASSIOPEIA_GIT_BRANCH \
-DKASPER_GIT_COMMIT=$KASSIOPEIA_GIT_COMMIT"
echo "User-defined git branch $KASSIOPEIA_GIT_BRANCH and commit $KASSIOPEIA_GIT_COMMIT"
fi
# Get script location
# https://stackoverflow.com/a/246128
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
mkdir -p $KASSIOPEIA_BUILD_PREFIX
pushd $KASSIOPEIA_BUILD_PREFIX
cmake -DCMAKE_BUILD_TYPE=$KASSIOPEIA_BUILD_TYPE \
-DCMAKE_INSTALL_PREFIX=$KASSIOPEIA_INSTALL_PREFIX \
-DKASPER_USE_ROOT=ON \
-DKASPER_USE_VTK=ON \
-DKASPER_USE_GSL=ON \
-DKEMField_USE_OPENCL=OFF \
-DBUILD_KASSIOPEIA=ON \
-DBUILD_KEMFIELD=ON \
-DBUILD_KGEOBAG=ON \
-DBUILD_KOMMON=ON \
-DBUILD_UNIT_TESTS=ON \
$KASSIOPEIA_CUSTOM_CMAKE_ARGS \
$GIT_ARGS \
$DIR
if [[ ! -z $KASSIOPEIA_CPUS ]]
then
$KASSIOPEIA_MAKECMD -j $KASSIOPEIA_CPUS
fi
$KASSIOPEIA_MAKECMD install
popd