-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sh
75 lines (58 loc) · 1.86 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
66
67
68
69
70
71
72
73
74
75
#!/bin/bash
red=`tput setaf 1`
reset=`tput sgr0`
# $1 debug or release
build_type=$1
compiler=$(echo ${CXX##*/})
number_of_build_workers=8
allow_omp=$2
allow_mpi=$3
if [ "$allow_omp" == "ON" ] || [ "$allow_omp" == "on" ] || [ "$allow_omp" == "OFF" ] || [ "$allow_omp" == "off" ]; then
allow_omp=$allow_omp
elif [[ "$compiler" == *"g++"* ]]; then
allow_omp=ON;
else
allow_omp=OFF;
fi
if [ "$allow_mpi" == "ON" ] || [ "$allow_mpi" == "on" ] || [ "$allow_mpi" == "OFF" ] || [ "$allow_mpi" == "off" ]; then
allow_omp=$allow_mpi
elif [[ "$compiler" == *"g++"* ]]; then
allow_omp=ON;
else
allow_omp=OFF;
fi
if [ "$build_type" == "" ]; then
rm -rf build_release
mkdir -p build_release
cd build_release
cmake .. -DCMAKE_BUILD_TYPE="Release" -DOMP=$allow_omp -DMPI=$allow_mpi
cd ..
rm -rf build_debug
mkdir -p build_debug
cd build_debug
cmake .. -DCMAKE_BUILD_TYPE="Debug" -DOMP=$allow_omp -DMPI=$allow_mpi
cd ..
cd build_debug && cmake --build . --target install -- -j${number_of_build_workers} && cd ..
cd build_release && cmake --build . --target install -- -j${number_of_build_workers} && cd ..
elif [ "$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 -DOMP=$allow_omp -DMPI=$allow_mpi
cmake --build . --target install -- -j8
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 -DOMP=$allow_omp -DMPI=$allow_mpi
cmake --build . --target install -- -j8
cd ..
else
echo ${red}"Unknown build type - Allowed only [Debug, Release]"${reset}
exit 1
fi