-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sh
executable file
·52 lines (40 loc) · 903 Bytes
/
build.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
#!/bin/bash
# SPDX-FileCopyrightText: Contributors to the Power Grid Model project <[email protected]>
#
# SPDX-License-Identifier: MPL-2.0
set -e
usage() {
echo "Usage: $0 -p <preset> [-i]" 1>&2
echo " -i option to install package"
cmake --list-presets
exit 1
}
while getopts "p::i" flag; do
case "${flag}" in
p)
PRESET=${OPTARG}
;;
i) INSTALL=1;;
*) usage ;;
esac
done
if [ -z "${PRESET}" ] ; then
usage
fi
echo "PRESET = ${PRESET}"
echo "INSTALL = ${INSTALL}"
BUILD_DIR=cpp_build/${PRESET}
INSTALL_DIR=install/${PRESET}
echo "Build dir: ${BUILD_DIR}"
echo "Install dir: ${INSTALL_DIR}"
rm -rf ${BUILD_DIR}/
# generate
cmake --preset ${PRESET}
# build
cmake --build --preset ${PRESET} --verbose -j1
# test
ctest --preset ${PRESET} --output-on-failure
# install
if [[ ${INSTALL} ]]; then
cmake --build --preset ${PRESET} --target install
fi