forked from cosmoscout/cosmoscout-vr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
make.sh
executable file
·72 lines (54 loc) · 3.32 KB
/
make.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
#!/bin/bash
# ------------------------------------------------------------------------------------------------ #
# This file is part of CosmoScout VR #
# and may be used under the terms of the MIT license. See the LICENSE file for details. #
# Copyright: (c) 2019 German Aerospace Center (DLR) #
# ------------------------------------------------------------------------------------------------ #
# Exit on error.
set -e
# ------------------------------------------------------------------------------------------------ #
# Default build mode is release, if "export COSMOSCOUT_DEBUG_BUILD=true" is executed before, the #
# application will be built in debug mode. #
# Usage: #
# ./make_release.sh [additional CMake flags, defaults to -G "Eclipse CDT4 - Unix Makefiles"] #
# Examples: #
# ./make_release.sh #
# ./make_release.sh -G "Unix Makefiles" #
# ./make_release.sh -G "Eclipse CDT4 - Unix Makefiles" -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \ #
# -DCMAKE_C_COMPILER_LAUNCHER=ccache #
# ------------------------------------------------------------------------------------------------ #
# create some required variables -------------------------------------------------------------------
# The CMake generator and other flags can be passed as parameters.
CMAKE_FLAGS=(-G "Eclipse CDT4 - Unix Makefiles")
if [ $# -ne 0 ]; then
CMAKE_FLAGS=( "$@" )
fi
# Check if ComoScout VR debug build is enabled with "export COSMOSCOUT_DEBUG_BUILD=true".
BUILD_TYPE=release
case "$COSMOSCOUT_DEBUG_BUILD" in
(true) echo "CosmoScout VR debug build is enabled!"; BUILD_TYPE=debug;;
esac
# This directory should contain the top-level CMakeLists.txt - it is assumed to reside in the same
# directory as this script.
CMAKE_DIR="$( cd "$( dirname "$0" )" && pwd )"
# Get the current directory - this is the default location for the build and install directory.
CURRENT_DIR="$(pwd)"
# The build directory.
BUILD_DIR="$CURRENT_DIR/build/linux-$BUILD_TYPE"
# The install directory.
INSTALL_DIR="$CURRENT_DIR/install/linux-$BUILD_TYPE"
# This directory should be used as the install directory for make_externals.sh.
EXTERNALS_INSTALL_DIR="$CURRENT_DIR/install/linux-externals-$BUILD_TYPE"
# create the build directory if necessary ----------------------------------------------------------
if [ ! -d "$BUILD_DIR" ]; then
mkdir -p "$BUILD_DIR"
fi
# configure, compile & install ---------------------------------------------------------------------
cd "$BUILD_DIR"
cmake "${CMAKE_FLAGS[@]}" -DCMAKE_INSTALL_PREFIX="$INSTALL_DIR" \
-DCMAKE_BUILD_TYPE=$BUILD_TYPE -DCOSMOSCOUT_EXTERNALS_DIR="$EXTERNALS_INSTALL_DIR" \
-DCMAKE_EXPORT_COMPILE_COMMANDS=On "$CMAKE_DIR"
cmake --build . --target install --parallel 8
# Delete empty files installed by cmake
find "$INSTALL_DIR" -type d -empty -delete
echo "Finished successfully."