-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.sh
executable file
·58 lines (45 loc) · 1.34 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
#!/usr/bin/env bash
# configure bash environment
set -o errexit -o pipefail -o noclobber -o nounset
# declare project structure
CPPCON_ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
is_command_installed () {
if [ $# -eq 0 ]; then return 1; fi
for cmd in "$@"; do
if ! hash "$cmd" 2>/dev/null; then
return 1
fi
done
return 0
}
build_build () {
local dir_source="${CPPCON_ROOT_DIR}"
local dir_build="${dir_source}/build"
mkdir -p "${dir_build}"
if case $OSTYPE in linux* | darwin*) false;; *) true;; esac; then
printf "recipe not implemented for windows."
return 1;
fi
local buildtype="Release"
local cmake_generator="Unix Makefiles"
if is_command_installed "ninja"; then
cmake_generator="Ninja"
fi
local cmake_config_optional_args=()
if is_command_installed "ccache"; then
cmake_config_optional_args+=(
-DCMAKE_C_COMPILER_LAUNCHER=ccache
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache
)
fi
local cmake_config_general_args=(
-B"${dir_build}"
-H"${dir_source}"
-G"${cmake_generator}"
-DCMAKE_BUILD_TYPE="${buildtype}"
"${cmake_config_optional_args[@]}"
)
cmake "${cmake_config_general_args[@]}"
cmake --build "${dir_build}" --parallel
}
build_build