-
Notifications
You must be signed in to change notification settings - Fork 10
/
bootstrap.sh
executable file
·60 lines (52 loc) · 1.5 KB
/
bootstrap.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
#!/bin/bash -e
USAGE="Usage: $0 [options]
Bootstraps the riesling build system (specifies the toolchain for CMake)
Options:
-i DIR Install riesling to this directory, e.g. $HOME/.local
-j N Restrict parallel build to this many threads
-h Print this message
"
PAR=""
PREFIX=""
while getopts "f:hi:j:" opt; do
case $opt in
i) PREFIX="-DCMAKE_INSTALL_PREFIX=$OPTARG -DCMAKE_PREFIX_PATH=$OPTARG";;
j) export VCPKG_MAX_CONCURRENCY=$OPTARG
PAR="-j $OPTARG";;
h) echo "$USAGE"
return;;
esac
done
shift $((OPTIND - 1))
# Use Ninja if available, otherwise CMake default
if [ -x "$( command -v ninja )" ]; then
GEN="-GNinja"
else
GEN=""
fi
# If vcpkg is not installed, install it
if [[ (-x "$( command -v vcpkg )") && (-n $VCPKG_ROOT) ]]; then
echo "vcpkg installed"
else
git clone https://github.com/microsoft/vcpkg.git .vcpkg
cd .vcpkg && ./bootstrap-vcpkg.sh && cd ..
export VCPKG_ROOT="$PWD/.vcpkg"
export PATH="$VCPKG_ROOT:$PATH"
fi
# Check for Magick++ and build montage if available
if [ -x "$( command -v Magick++-config )" ]; then
MONTAGE="-DBUILD_MONTAGE=ON"
else
MONTAGE=""
fi
mkdir -p build
cmake -S . -B build $GEN \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_TOOLCHAIN_FILE="${VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake" \
-DCMAKE_CXX_FLAGS_RELWITHDEBINFO="-O2 -g -fsanitize=address,undefined" \
-DVCPKG_INSTALL_OPTIONS="--no-print-usage" \
$PREFIX $MONTAGE
cmake --build build $PAR
if [ -n "$PREFIX" ]; then
cmake --install build
fi