-
Notifications
You must be signed in to change notification settings - Fork 19
/
example_build_script
executable file
·301 lines (209 loc) · 6.8 KB
/
example_build_script
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
#!/bin/bash
#
# Example script for building dependencies and xReg.
# This is not pretty, but can be used in a pinch and serves well to illustrate
# the settings used for achieving a successful build.
# stop after the first failed command
set -e
NEED_TO_DOWNLOAD=true
NEED_TO_BUILD_THIRD_PARTY=true
NEED_TO_START_XREG=true
DO_GUI=true
#BUILD_CONFIG="Debug"
BUILD_CONFIG="Release"
# directory of the xReg repo, assuming this script was invoked while in that directory
XREG_DIR="`pwd`"
XREG_BUILD_DIR="$XREG_DIR/build"
# Set this to a directory outside of the xReg repo in which to download and build dependencies
DEPS_DIR="$XREG_DIR/../xreg_deps"
# get rid of the repository prefix in the path:
DEPS_DIR="$(cd "$(dirname "$DEPS_DIR")"; pwd)/$(basename "$DEPS_DIR")"
mkdir -p $DEPS_DIR
cd $DEPS_DIR
if ! [ -x "$(command -v wget)" ]; then
echo "wget is not available, using a wrapper to curl instead."
function wget()
{
FILENAME_TO_DOWNLOAD=`basename $1`
echo "Downloading $FILENAME_TO_DOWNLOAD ..."
curl -L -O $1
}
fi
if [ "$NEED_TO_DOWNLOAD" = true ]; then
echo "Downloading third party libraries..."
# Choose the TBB package for your operating system:
OS_STR=`uname -s`
if [ "$OS_STR" == "Darwin" ]; then
TBB_URL="https://github.com/intel/tbb/releases/download/2018_U1/tbb2018_20170919oss_mac.tgz"
elif [ "$OS_STR" == "Linux" ]; then
TBB_URL="https://github.com/intel/tbb/releases/download/2018_U1/tbb2018_20170919oss_lin.tgz"
else
TBB_URL="https://github.com/intel/tbb/releases/download/2018_U1/tbb2018_20170919oss_win.zip"
fi
TBB_FILE=`basename $TBB_URL`
wget $TBB_URL
tar xf $TBB_FILE
rm $TBB_FILE
BOOST_URL="https://boostorg.jfrog.io/artifactory/main/release/1.74.0/source/boost_1_74_0.zip"
BOOST_FILE=`basename $BOOST_URL`
wget $BOOST_URL
unzip -q $BOOST_FILE
rm $BOOST_FILE
EIGEN_URL="https://gitlab.com/libeigen/eigen/-/archive/3.3.4/eigen-3.3.4.zip"
EIGEN_FILE=`basename $EIGEN_URL`
wget $EIGEN_URL
unzip -q $EIGEN_FILE
rm $EIGEN_FILE
VIENNACL_URL="https://github.com/viennacl/viennacl-dev/archive/release-1.7.1.zip"
VIENNACL_FILE=`basename $VIENNACL_URL`
wget $VIENNACL_URL
unzip -q $VIENNACL_FILE
rm $VIENNACL_FILE
FMT_URL="https://github.com/fmtlib/fmt/archive/5.3.0.zip"
FMT_FILE=`basename $FMT_URL`
wget $FMT_URL
unzip -q $FMT_FILE
rm $FMT_FILE
NLOPT_URL="https://github.com/stevengj/nlopt/archive/v2.5.0.zip"
NLOPT_FILE=`basename $NLOPT_URL`
wget $NLOPT_URL
unzip -q $NLOPT_FILE
rm $NLOPT_FILE
VTK_URL="https://www.vtk.org/files/release/8.2/VTK-8.2.0.zip"
wget $VTK_URL
VTK_FILE=`basename $VTK_URL`
unzip -q $VTK_FILE
rm $VTK_FILE
ITK_URL="https://github.com/InsightSoftwareConsortium/ITK/releases/download/v5.2.1/InsightToolkit-5.2.1.zip"
ITK_FILE=`basename $ITK_URL`
wget $ITK_URL
unzip -q $ITK_FILE
rm $ITK_FILE
OPENCV_URL="https://github.com/opencv/opencv/archive/3.4.12.zip"
OPENCV_FILE=`basename $OPENCV_URL`
wget $OPENCV_URL
unzip -q $OPENCV_FILE
rm $OPENCV_FILE
fi
TBB_INC_DIR="$DEPS_DIR/tbb2018_20170919oss/include"
TBB_DIR="$DEPS_DIR/tbb2018_20170919oss/cmake"
BOOST_DIR="$DEPS_DIR/`ls | grep "boost_*"`"
EIGEN_DIR="$DEPS_DIR/`ls | grep "eigen-*"`"
VIENNACL_DIR="$DEPS_DIR/`ls | grep "viennacl-dev-release-*"`"
FMT_DIR="$DEPS_DIR/`ls | grep "fmt-*"`"
NLOPT_DIR="$DEPS_DIR/`ls | grep "nlopt-*"`"
VTK_DIR="$DEPS_DIR/`ls | grep "VTK-*"`"
ITK_DIR="$DEPS_DIR/`ls | grep "InsightToolkit-*"`"
OPENCV_DIR="$DEPS_DIR/`ls | grep "opencv-*"`"
if [ "$NEED_TO_BUILD_THIRD_PARTY" = true ] ; then
echo "Building third-party libraries..."
cd $FMT_DIR
mkdir build
cd build
cmake -G Ninja .. \
-DCMAKE_CXX_STANDARD:STRING="11" \
-DCMAKE_BUILD_TYPE:STRING=$BUILD_CONFIG \
-DFMT_USE_CPP11:BOOL=ON \
-DFMT_TEST:BOOL=OFF \
-DFMT_INSTALL:BOOL=ON \
-DFMT_DOC:BOOL=OFF
ninja
cd ../../
cd $NLOPT_DIR
mkdir build
cd build
cmake -G Ninja .. \
-DCMAKE_CXX_STANDARD:STRING="11" \
-DCMAKE_BUILD_TYPE:STRING=$BUILD_CONFIG \
-DBUILD_SHARED_LIBS:BOOL=OFF \
-DNLOPT_CXX:BOOL=OFF \
-DNLOPT_PYTHON:BOOL=OFF \
-DNLOPT_OCTAVE:BOOL=OFF \
-DNLOPT_MATLAB:BOOL=OFF \
-DNLOPT_GUILE:BOOL=OFF \
-DNLOPT_SWIG:BOOL=OFF \
-DNLOPT_LINK_PYTHON:BOOL=OFF
ninja
cd ../../
cd $VTK_DIR
mkdir build
cd build
VTK_NO_RENDER_FLAGS=""
if [ "$DO_GUI" = false ]; then
VTK_NO_RENDER_FLAGS="-DVTK_RENDERING_BACKEND=None -DVTK_Group_Rendering:BOOL=OFF"
fi
TBB_ROOT="$TBB_INC_DIR/.." cmake -G Ninja .. \
-DCMAKE_CXX_STANDARD:STRING="11" \
-DCMAKE_BUILD_TYPE:STRING=$BUILD_CONFIG \
-DBUILD_SHARED_LIBS:BOOL=OFF \
-DVTK_Group_Imaging:BOOL=ON \
-DVTK_Group_Views:BOOL=ON \
-DBUILD_TESTING:BOOL=OFF \
-DVTK_SMP_IMPLEMENTATION_TYPE:STRING="TBB" $VTK_NO_RENDER_FLAGS
ninja
cd ../..
cd $ITK_DIR
mkdir build
cd build
cmake -G Ninja .. \
-DCMAKE_CXX_STANDARD:STRING="11" \
-DCMAKE_BUILD_TYPE:STRING=$BUILD_CONFIG \
-DBUILD_SHARED_LIBS:BOOL=OFF \
-DBUILD_TESTING:BOOL=OFF \
-DBUILD_EXAMPLES:BOOL=OFF \
-DITK_USE_GPU:BOOL=OFF \
-DModule_ITKReview:BOOL=ON \
-DModule_LabelErodeDilate:BOOL=ON
ninja
cd ../..
cd $OPENCV_DIR
mkdir build
cd build
# Need to set this OFF on MARCC (and other systems without the necessary deps)
OPENCV_GUI_FLAGS=""
if [ "$DO_GUI" = false ]; then
OPENCV_GUI_FLAGS="-DBUILD_opencv_highgui:BOOL=OFF -DWITH_GSTREAMER:BOOL=OFF"
fi
# On Ubuntu 14.04, you may need to add this:
# -DWITH_LAPACK=OFF
cmake -G Ninja .. \
-DCMAKE_CXX_STANDARD:STRING="11" \
-DCMAKE_BUILD_TYPE:STRING=$BUILD_CONFIG \
-DBUILD_SHARED_LIBS:BOOL=OFF \
-DBUILD_TESTS:BOOL=OFF \
-DBUILD_EXAMPLES:BOOL=OFF \
-DBUILD_DOCS:BOOL=OFF \
-DBUILD_WITH_DEBUG_INFO:BOOL=OFF \
-DWITH_TBB:BOOL=OFF \
-DBUILD_TBB:BOOL=OFF \
-DWITH_IPP:BOOL=OFF \
-DWITH_VTK:BOOL=OFF \
-DWITH_CUBLAS:BOOL=OFF \
-DWITH_CUDA:BOOL=OFF \
-DWITH_CUFFT:BOOL=OFF \
-DWITH_OPENCL:BOOL=OFF \
-DWITH_EIGEN:BOOL=OFF \
-DBUILD_opencv_python2:BOOL=OFF \
-DBUILD_opencv_python3:BOOL=OFF $OPENCV_GUI_FLAGS
ninja
cd ../..
fi
# START: XREG BUILD:
if [ "$NEED_TO_START_XREG" = true ]; then
mkdir $XREG_BUILD_DIR
cd $XREG_BUILD_DIR
cmake -G Ninja .. \
-DCMAKE_BUILD_TYPE:STRING=$BUILD_CONFIG \
-DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=ON \
-DViennaCL_DIR:PATH="$VIENNACL_DIR" \
-DEIGEN3_INCLUDE_DIR:PATH="$EIGEN_DIR" \
-DBoost_INCLUDE_DIR:PATH="$BOOST_DIR" \
-DNLopt_DIR:BOOL="$NLOPT_DIR/build" \
-DTBB_DIR:PATH="$TBB_DIR" \
-Dfmt_DIR:PATH="$FMT_DIR/build" \
-DVTK_DIR:PATH="$VTK_DIR/build" \
-DITK_DIR:PATH="$ITK_DIR/build" \
-DOpenCV_DIR:PATH="$OPENCV_DIR/build" \
-DXREG_INCLUDE_GIT_HASH_IN_VER_STR:BOOL=ON
ninja
fi