forked from cosmoscout/cosmoscout-vr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
make.sh
executable file
·86 lines (65 loc) · 3.74 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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#!/bin/bash
# ------------------------------------------------------------------------------------------------ #
# This file is part of CosmoScout VR #
# ------------------------------------------------------------------------------------------------ #
# SPDX-FileCopyrightText: German Aerospace Center (DLR) <[email protected]>
# SPDX-License-Identifier: MIT
# 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.sh [additional CMake flags, defaults to -G "Eclipse CDT4 - Unix Makefiles"] #
# Examples: #
# ./make.sh #
# ./make.sh -G "Unix Makefiles" #
# ./make.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
# Check if unity build is enabled with "export COSMOSCOUT_USE_UNITY_BUILD=true".
UNITY_BUILD=Off
case "$COSMOSCOUT_USE_UNITY_BUILD" in
(true) echo "Unity build is enabled!"; UNITY_BUILD=On;
esac
# Check if precompiled headers should be used with "export COSMOSCOUT_USE_PCH=true".
PRECOMPILED_HEADERS=Off
case "$COSMOSCOUT_USE_PCH" in
(true) echo "Precompiled headers are enabled!"; PRECOMPILED_HEADERS=On;
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_UNITY_BUILD=$UNITY_BUILD -DCOSMOSCOUT_USE_PRECOMPILED_HEADERS=$PRECOMPILED_HEADERS \
-DCMAKE_EXPORT_COMPILE_COMMANDS=On "$CMAKE_DIR"
cmake --build . --target install --parallel "$(nproc)"
# Delete empty files installed by cmake
find "$INSTALL_DIR" -type d -empty -delete
echo "Finished successfully."