-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·84 lines (71 loc) · 1.93 KB
/
build.sh
File metadata and controls
executable file
·84 lines (71 loc) · 1.93 KB
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
#!/bin/bash
set -euo pipefail
help()
{
echo "Basic script to build mercator"
echo
echo "Syntax: ./build.sh [-b|-s]"
echo "options:"
echo "h Print this help."
echo "b [BUILD_TYPE] Build type: {Release, Debug}."
echo "s [SYSTEM] OS type: {win, linux, mac}."
echo
}
while getopts ":hb:s:" option; do
case $option in
h)
help
exit;;
b)
build_type=$OPTARG;;
s)
os_type=$OPTARG;;
\?)
echo "Error: Invalid option"
exit;;
esac
done
if [[ -z "${build_type:-}" ]]; then
build_type="Release"
fi
if [[ -z "${os_type:-}" ]]; then
case "$(uname -s)" in
Darwin)
os_type="mac"
;;
*)
os_type="linux"
;;
esac
fi
mkdir -p build && cd build/ # go to build folder
#export OMP_NUM_THREADS=$(nproc)
# Windows 10
if [[ $os_type == "win" ]]; then
cmake .. -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=$build_type
cmake --build . --config $build_type -j 8
fi
# Linux or Mac
if [[ "$os_type" == "linux" || "$os_type" == "mac" ]]; then
cmake_args=(.. -G "Unix Makefiles" -DCMAKE_BUILD_TYPE="$build_type")
if [[ "$os_type" == "mac" ]]; then
if [[ -n "${SDKROOT:-}" && ! -d "${SDKROOT}" ]]; then
echo "Warning: SDKROOT points to a missing path (${SDKROOT}); unsetting it for this build."
unset SDKROOT
fi
macos_sdk_path=""
if command -v xcrun >/dev/null 2>&1; then
macos_sdk_path="$(xcrun --sdk macosx --show-sdk-path 2>/dev/null || true)"
fi
# Override stale cached sysroots from older Xcode/CLT installations.
cmake_args+=("-DCMAKE_OSX_SYSROOT=${macos_sdk_path}")
fi
cmake "${cmake_args[@]}"
cmake --build . -j 8
fi
if [[ -f bmercator ]]; then
mv bmercator ../ # copy mercator to project directory
else
echo "Error: build completed without producing ./build/bmercator."
exit 1
fi