-
Notifications
You must be signed in to change notification settings - Fork 2
/
build_submodules.sh
executable file
·81 lines (64 loc) · 1.93 KB
/
build_submodules.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
#!/usr/bin/env bash
MYPWD=$(pwd)
set -x
set -e
GCC=gcc
GXX=g++
BUILD_TYPE=RelWithDebInfo
if [ -n "$1" ]; then
BUILD_TYPE=$1
fi
# https://stackoverflow.com/a/45181694
NUM_CORES=`getconf _NPROCESSORS_ONLN 2>/dev/null || sysctl -n hw.ncpu || echo 1`
NUM_PARALLEL_BUILDS=$((NUM_CORES - 2 < 1 ? 1 : NUM_CORES - 2))
CXX_MARCH=native
EIGEN_DIR="$MYPWD/thirdparty/eigen"
COMMON_CMAKE_ARGS=(
-DCMAKE_C_COMPILER=${GCC}
-DCMAKE_CXX_COMPILER=${GXX}
-DCMAKE_C_COMPILER_LAUNCHER=ccache
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache
-DCMAKE_BUILD_TYPE=${BUILD_TYPE}
-DCMAKE_EXPORT_NO_PACKAGE_REGISTRY=ON
-DCMAKE_CXX_FLAGS="-march=$CXX_MARCH -O3 -Wno-deprecated-declarations -Wno-null-pointer-arithmetic -Wno-unknown-warning-option -Wno-unused-function" # -Wno-int-in-bool-context
)
BUILD_CERES=thirdparty/build-ceres-solver
BUILD_SPDLOG=thirdparty/build-spdlog
BUILD_OPENMESH=thirdparty/build-openmesh
BUILD_DLIB=thirdparty/build-dlib
git submodule sync --recursive
git submodule update --init --recursive
sudo rm -rf "$BUILD_CERES"
sudo rm -rf "$BUILD_SPDLOG"
sudo rm -rf "$BUILD_OPENMESH"
sudo rm -rf "$BUILD_DLIB"
mkdir -p "$BUILD_SPDLOG"
pushd "$BUILD_SPDLOG"
cmake ../spdlog "${COMMON_CMAKE_ARGS[@]}" \
-DCMAKE_BUILD_TYPE=Release \
-DSPDLOG_BUILD_SHARED=OFF \
-DSPDLOG_FMT_EXTERNAL=OFF \
-DSPDLOG_BUILD_EXAMPLE=OFF \
-DSPDLOG_BUILD_TESTS=OFF \
-DCMAKE_INSTALL_PREFIX=install
make -j$NUM_PARALLEL_BUILDS install
popd
mkdir -p "$BUILD_CERES"
pushd "$BUILD_CERES"
cmake ../ceres-solver "${COMMON_CMAKE_ARGS[@]}" \
"-DEIGEN_INCLUDE_DIR_HINTS=$EIGEN_DIR" \
-DBUILD_EXAMPLES=OFF \
-DBUILD_TESTING=OFF \
-DEXPORT_BUILD_DIR=ON
make -j$NUM_PARALLEL_BUILDS ceres
popd
mkdir -p "$BUILD_OPENMESH"
pushd "$BUILD_OPENMESH"
cmake ../OpenMesh "${COMMON_CMAKE_ARGS[@]}"
sudo make -j$NUM_PARALLEL_BUILDS install
popd
mkdir -p "$BUILD_DLIB"
pushd "$BUILD_DLIB"
cmake ../dlib "${COMMON_CMAKE_ARGS[@]}"
sudo make -j$NUM_PARALLEL_BUILDS install
popd