-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sh
executable file
·45 lines (34 loc) · 1.15 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
#!/bin/bash
red=$(tput setaf 196)
green=$(tput setaf 10)
reset=$(tput sgr0)
# get the directory of the current bash script (independently by the execution path)
scriptdir=$(dirname $(readlink /proc/$$/fd/255))
pushd $scriptdir > "/dev/null"
# $1 debug or release
build_type=$1
number_of_build_workers=$(grep -c ^processor /proc/cpuinfo)
other_cmake_flags="${@:2}"
if [ "$build_type" == "Release" ] || [ "$build_type" == "release" ]; then
echo "${green}Building Release project${reset}"
build_type=Release
#rm -rf build_release
mkdir -p build_release
cd build_release
cmake .. -DCMAKE_BUILD_TYPE=$build_type $other_cmake_flags
cmake --build . --target install --parallel $number_of_build_workers
cd ..
elif [ "$build_type" == "Debug" ] || [ "$build_type" == "debug" ]; then
echo "${green}Building Debug project${reset}"
build_type=Debug
#rm -rf build_debug
mkdir -p build_debug
cd build_debug
cmake .. -DCMAKE_BUILD_TYPE=$build_type $other_cmake_flags
cmake --build . --target install --parallel $number_of_build_workers
cd ..
else
echo "${red}Unknown build type - Allowed only [Debug, Release]${reset}"
exit 1
fi
popd > /dev/null