-
Notifications
You must be signed in to change notification settings - Fork 0
/
cmake_install.sh
71 lines (61 loc) · 1.96 KB
/
cmake_install.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
# build directory name can be a parameter -d
# build type can be a parameter -t
BUILDDIR="build"
BUILDTYPE="Release"
DELBUILD=false
# check number of cores
nproc=$(nproc)
# subtract one
nproc=$((nproc-1))
while getopts d:t:e:j:c:b: option
do
case "${option}"
in
d) BUILDDIR=${OPTARG};;
t) BUILDTYPE=${OPTARG};;
e) DELBUILD=true;;
j) nproc=${OPTARG};;
c) ACTIVATE_DECODING=false;;
B) BASEDIR=${OPTARG};;
esac
done
if [ "$DELBUILD" = true ] ; then
echo "Deleting build directory"
if [ -d "$BUILDDIR" ]; then
rm -rf $BUILDDIR
fi
fi
# store current directory in variable
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
if [ -n "$BASEDIR" ]; then
DIR=$BASEDIR
fi
# abort if build directory exists
if [ -d "$DIR/$BUILDDIR" ]; then
echo "Build directory exists. Aborting."
exit 1
fi
# create build directory
mkdir -p $DIR/$BUILDDIR
# CMAKE Options
GENERATOR="Unix Makefiles"
# libdatachannel options
LIBDATACHANNEL_BUILD_TESTS="-DLIBDATACHANNEL_BUILD_TESTS=Off"
LIBDATACHANNEL_BUILD_EXAMPLES="-DLIBDATACHANNEL_BUILD_EXAMPLES=Off"
LIBDATACHANNEL_SETTINGS="-DENABLE_DEBUG_LOGGING=On -DENABLE_LOCALHOST_ADDRESS=On -DENABLE_LOCAL_ADDRESS_TRANSLATION=On"
# basic stuff
PYTHON_INCLUDE_DIRS=$(python3 -c "from distutils.sysconfig import get_python_inc; print(get_python_inc())")
PYTHON_LIBRARY=$(python -c "import sysconfig; print(sysconfig.get_config_var('LIBDIR'))")
echo "Python include dir: $PYTHON_INCLUDE_DIRS"
# synavis options if DECODING is set
DECODING=""
if [ "$ACTIVATE_DECODING" = true ] ; then
echo "Activating decoding"
DECODING="-DBUILD_WITH_DECODING=On"
fi
#cmake verbose option
CMAKE_VERBOSE="-DCMAKE_VERBOSE_MAKEFILE=On"
# configure
cmake -H$DIR -B$DIR/$BUILDDIR -DCMAKE_BUILD_TYPE=$BUILDTYPE -G "$GENERATOR" $LIBDATACHANNEL_VERBOSELOGGING $LIBDATACHANNEL_BUILD_TESTS $LIBDATACHANNEL_BUILD_EXAMPLES $LIBDATACHANNEL_SETTINGS $DECODING -DPYTHON_INCLUDE_DIR=$PYTHON_INCLUDE_DIRS -DPYTHON_LIBRARY=$PYTHON_LIBRARY
# build
cmake --build $DIR/$BUILDDIR -- -j $nproc