-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.sh
executable file
·65 lines (57 loc) · 1.22 KB
/
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
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/bin/sh
# Copyright (c) Brandon Pacewic
# SPDX-License-Identifier: MIT
set -e
BUILD_DIR="build"
BUILD_TESTS=ON
RUN_TESTS=OFF
BUILD_BENCH=OFF
BUILD_TOOLS=OFF
CMAKE_GENERATOR="Unix Makefiles"
while [ $# -gt 0 ]; do
case "$1" in
--clean)
rm -rf "$BUILD_DIR"
shift
;;
--build-tests)
BUILD_TESTS=OFF
shift
;;
--test)
RUN_TESTS=ON
shift
;;
--bench)
BUILD_BENCH=ON
shift
;;
--tools)
BUILD_TOOLS=ON
shift
;;
--build-dir=*)
BUILD_DIR="${1#*=}"
shift
;;
--help)
echo "Usage: $0 [--clean] [--build-tests] [--test] [--bench] [--tools] [--build-dir=<dir>] [--help]"
exit 0
;;
*)
echo "Unknown option: $1"
exit 1
;;
esac
done
mkdir -p "$BUILD_DIR"
cd "$BUILD_DIR"
cmake -G "$CMAKE_GENERATOR" \
-DBUILD_TESTING="$BUILD_TESTS" \
-DBUILD_BENCHMARKS="$BUILD_BENCH" \
-DBUILD_TOOLS="$BUILD_TOOLS" \
..
make
if [ "$RUN_TESTS" = "ON" ]; then
ctest --output-on-failure
fi