-
Notifications
You must be signed in to change notification settings - Fork 0
/
compile.sh
executable file
·55 lines (48 loc) · 1.36 KB
/
compile.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
#!/bin/sh
################################################################################
# compile.sh
#
# Part of Project Thrill - http://project-thrill.org
#
# Copyright (C) 2016 Timo Bingmann <[email protected]>
#
# All rights reserved. Published under the BSD-2 license in the LICENSE file.
################################################################################
set -ex
CMAKE_OPTS="-DCMAKE_BUILD_TYPE=Release"
# try to find a modern C++ compiler
set +x
COMPILERS_LIST=
for MAJOR in `seq 9 -1 4`; do
COMPILERS_LIST="$COMPILERS_LIST $MAJOR"
for MINOR in `seq 9 -1 0`; do
COMPILERS_LIST="$COMPILERS_LIST $MAJOR.$MINOR"
for PATCH in `seq 9 -1 0`; do
COMPILERS_LIST="$COMPILERS_LIST $MAJOR.$MINOR.$PATCH"
done
done
done
#echo $COMPILERS_LIST
for CMD in $COMPILERS_LIST; do
if command -v "g++-$CMD" > /dev/null; then
CMAKE_OPTS="$CMAKE_OPTS -DCMAKE_C_COMPILER=gcc-$CMD -DCMAKE_CXX_COMPILER=g++-$CMD"
break
fi
done
set -x
# detect number of cores
if [ -e /proc/cpuinfo ]; then
CORES=$(grep -c ^processor /proc/cpuinfo)
elif [ "$(uname)" == "Darwin" ]; then
CORES=$(sysctl -n hw.ncpu)
else
CORES=4
fi
MAKEOPTS=-j$CORES
if [ ! -d "build" ]; then
mkdir build
fi
cd build
cmake .. $CMAKE_OPTS $@
make $MAKEOPTS
################################################################################