forked from OpenFOAM/ThirdParty-7
-
Notifications
You must be signed in to change notification settings - Fork 0
/
makeCGAL
executable file
·310 lines (269 loc) · 8.67 KB
/
makeCGAL
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
301
302
303
304
305
306
307
308
309
310
#!/bin/sh
#------------------------------------------------------------------------------
# ========= |
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration |
# \\ / A nd | Copyright (C) 2012-2018 OpenFOAM Foundation
# \\/ M anipulation |
#------------------------------------------------------------------------------
# License
# This file is part of OpenFOAM.
#
# OpenFOAM is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# for more details.
#
# You should have received a copy of the GNU General Public License
# along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
#
# Script
# makeCGAL
#
# Description
# Build script for CGAL
#
# Note
# Normally builds against ThirdParty boost and gmp/mpfr when possible.
# To override this behaviour (and use the system boost and/or gmp/mpfr),
# simply specify a 'system' version. For example,
# makeCGAL boost-system gmp-system
#
# Mixing system and ThirdParty for gmp/mpfr is not supported.
#
#------------------------------------------------------------------------------
# Get CGAL, boost and gmp/mpfr versions
. $WM_PROJECT_DIR/etc/config.sh/functions
_foamEval $($WM_PROJECT_DIR/bin/foamEtcFile config.sh/CGAL)
_foamSource $($WM_PROJECT_DIR/bin/foamEtcFile config.sh/compiler)
cgalPACKAGE=${cgal_version:-CGAL-4.10}
boostPACKAGE=${boost_version:-boost-system}
gmpPACKAGE=${gmp_version:-gmp-system}
mpfrPACKAGE=${mpfr_version:-mpfr-system}
#------------------------------------------------------------------------------
# Run from third-party directory only
wmakeCheckPwd "$WM_THIRD_PARTY_DIR" || {
echo "Error: Current directory is not \$WM_THIRD_PARTY_DIR"
echo " The environment variables are inconsistent with the installation."
echo " Check the OpenFOAM entries in your dot-files and source them."
exit 1
}
. etc/tools/ThirdPartyFunctions
#------------------------------------------------------------------------------
usage() {
exec 1>&2
while [ "$#" -ge 1 ]; do echo "$1"; shift; done
cat<<USAGE
usage: ${0##*/} [OPTION] [CGAL-VERSION] [boost-VERSION] [gmp-VERSION] [mpfr-VERSION]
options:
-gcc force g++ instead of the value from \$WM_CXX
-help
* build CGAL with
$cgalPACKAGE
$boostPACKAGE
$gmpPACKAGE
$mpfrPACKAGE
Normally builds against ThirdParty boost and gmp/mpfr when possible.
To override this behaviour (and use the system boost and/o gmp/mpfr),
simply specify a 'system' version. For example,
${0##*/} boost-system gmp-system
Note: mixing system and ThirdParty for gmp/mpfr is not supported.
USAGE
exit 1
}
# Ensure CMake gets the correct C++ compiler
[ -n "$WM_CXX" ] && export CXX="$WM_CXX"
# Parse options
while [ "$#" -gt 0 ]
do
case "$1" in
-h | -help)
usage
;;
-gcc)
export CXX=g++ # use g++
shift
;;
gmp-[4-9]* | gmp-sys*)
gmpPACKAGE="${1%%/}"
shift
;;
mpfr-[2-9]* | mpfr-sys*)
mpfrPACKAGE="${1%%/}"
shift
;;
CGAL-[0-9]*)
cgalPACKAGE="${1%%/}"
shift
;;
boost-[0-9]* | boost_[0-9]* | boost-sys* )
boostPACKAGE="${1%%/}"
shift
;;
*)
usage "unknown option/argument: '$*'"
;;
esac
done
#------------------------------------------------------------------------------
#
# Build Boost
#
# BOOST_SOURCE_DIR : location of the original sources
BOOST_ARCH_PATH=$installBASE/$boostPACKAGE
BOOST_SOURCE_DIR=$WM_THIRD_PARTY_DIR/$boostPACKAGE
if [ -d "$BOOST_ARCH_PATH" ]
then
boostInc="$BOOST_ARCH_PATH/include"
boostLib="$BOOST_ARCH_PATH/lib"
elif [ -d "$BOOST_SOURCE_DIR" ]
then
boostInc="$BOOST_ARCH_PATH/include"
boostLib="$BOOST_ARCH_PATH/lib"
toolset="$WM_CC"
if [ $WM_COMPILER == "Icc" ]; then
toolset=intel
fi
echo "Starting build: boost"
(
cd $BOOST_SOURCE_DIR || exit 1
rm -rf $BOOST_ARCH_PATH
./bootstrap.sh \
--prefix=$BOOST_ARCH_PATH \
--with-libraries=thread \
--with-libraries=system \
--with-libraries=atomic \
--with-libraries=chrono \
--with-libraries=date_time \
&& ./bjam toolset=$toolset -j $WM_NCOMPPROCS install \
&& echo "Built: boost"
) || {
echo "Error building: boost"
exit 1
}
else
boostInc="/usr/include"
# For completeness:
# 64-bit needs lib64, but 32-bit needs lib (not lib32)
if [ "$WM_ARCH_OPTION" = 64 ]
then
boostLib="/usr/lib$WM_ARCH_OPTION"
else
boostLib="/usr/lib"
fi
fi
# Retrieve boost version:
if [ -f "$boostInc/boost/version.hpp" ]
then
BOOST_VERSION_NO=`sed -ne 's/^#define *BOOST_VERSION *\([0-9][0-9]*\).*$/\1/p' $boostInc/boost/version.hpp`
else
echo "Boost does not appear to be installed"
echo "stopping build"
exit 1
fi
if [ "$cgal_version" = "cgal-system" ]
then
echo "Using system installation of CGAL"
exit 0
fi
#
# Build CGAL
#
# CGAL_SOURCE_DIR : location of the original sources
# CGAL_BINARY_DIR : location of the build
# CGAL_DIR : location of the installed program
CGAL_SOURCE_DIR=$WM_THIRD_PARTY_DIR/$cgalPACKAGE
CGAL_BINARY_DIR=$buildBASE/$cgalPACKAGE
CGAL_ARCH_PATH=$installBASE/$cgalPACKAGE
CGAL_DIR=$CGAL_ARCH_PATH
#
# gmp/mpfr installed without compiler name
installBASE=$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER_ARCH
GMP_ARCH_PATH=$installBASE/$gmpPACKAGE
MPFR_ARCH_PATH=$installBASE/$mpfrPACKAGE
(
# Remove any existing build folder and recreate
if [ -d $CGAL_BINARY_DIR ]
then
echo "removing old build directory"
echo " $CGAL_BINARY_DIR"
rm -rf $CGAL_BINARY_DIR
fi
mkdir -p $CGAL_BINARY_DIR
cd $CGAL_BINARY_DIR || exit 1
unset configBoost configGmpMpfr
echo "----"
echo "Configuring $cgalPACKAGE with boost $BOOST_VERSION_NO"
echo " Source : $CGAL_SOURCE_DIR"
echo " Build : $CGAL_BINARY_DIR"
echo " Target : $CGAL_DIR"
if [ -d "$BOOST_ARCH_PATH" ]
then
echo " ThirdParty : boost"
configBoost=$(cat <<CMAKE_OPTIONS
-DBoost_INCLUDE_DIR=$boostInc
-DBoost_LIBRARY_DIRS=$boostLib
-DBoost_THREAD_LIBRARY=$boostLib/libboost_thread.so
-DBoost_THREAD_LIBRARY_RELEASE=$boostLib/libboost_thread.so
-DBoost_SYSTEM_LIBRARY=$boostLib/libboost_system.so
-DBoost_SYSTEM_LIBRARY_RELEASE=$boostLib/libboost_system.so
-DBoost_VERSION=$BOOST_VERSION_NO
CMAKE_OPTIONS
)
else
echo " system : boost"
configBoost=$(cat <<CMAKE_OPTIONS
-DBOOST_LIBRARYDIR=$boostLib
CMAKE_OPTIONS
)
fi
if [ -d "$GMP_ARCH_PATH" -a -d "$MPFR_ARCH_PATH" ]
then
echo " ThirdParty : gmp/mpfr"
configGmpMpfr=$(cat <<CMAKE_OPTIONS
-DGMP_INCLUDE_DIR=$GMP_ARCH_PATH/include
-DGMP_LIBRARIES_DIR=$GMP_ARCH_PATH/lib$WM_COMPILER_LIB_ARCH
-DGMP_LIBRARIES=$GMP_ARCH_PATH/lib$WM_COMPILER_LIB_ARCH/libgmp.so
-DGMPXX_INCLUDE_DIR=$GMP_ARCH_PATH/include
-DGMPXX_LIBRARIES=$GMP_ARCH_PATH/lib$WM_COMPILER_LIB_ARCH/libgmpxx.so
-DMPFR_INCLUDE_DIR=$MPFR_ARCH_PATH/include
-DMPFR_LIBRARIES_DIR=$MPFR_ARCH_PATH/lib$WM_COMPILER_LIB_ARCH
-DMPFR_LIBRARIES=$MPFR_ARCH_PATH/lib$WM_COMPILER_LIB_ARCH/libmpfr.so
CMAKE_OPTIONS
)
else
echo " system : gmp/mpfr"
fi
echo "----"
set -x
cmake \
-DCMAKE_INSTALL_PREFIX=$CGAL_ARCH_PATH \
-DCMAKE_BUILD_TYPE=Release \
-DWITH_CGAL_Qt5=OFF \
-DCGAL_INSTALL_LIB_DIR=lib$WM_COMPILER_LIB_ARCH \
-DCGAL_CXX_FLAGS="-DCGAL_NO_DEPRECATED_CODE" \
$configBoost $configGmpMpfr \
$CGAL_SOURCE_DIR \
&& make -j $WM_NCOMPPROCS \
&& make install || exit 1
echo "----"
echo "create '\$CGAL_ARCH_PATH/share/files'"
echo "----"
mkdir -p $CGAL_ARCH_PATH/share/src
rm -f $CGAL_ARCH_PATH/share/files
for i in assertions.cpp io.cpp MP_Float.cpp Random.cpp
do
if [ -e "$CGAL_SOURCE_DIR/src/CGAL/$i" ]
then
\cp $CGAL_SOURCE_DIR/src/CGAL/$i $CGAL_ARCH_PATH/share/src/
echo "\${CGAL_ARCH_PATH}/share/src/$i" >> $CGAL_ARCH_PATH/share/files
fi
done
echo "Done CGAL"
)
#------------------------------------------------------------------------------