File: run_cmake.sh

package info (click to toggle)
cppad 2026.00.00.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 11,584 kB
  • sloc: cpp: 112,960; sh: 6,146; ansic: 179; python: 71; sed: 12; makefile: 10
file content (419 lines) | stat: -rwxr-xr-x 9,070 bytes parent folder | download
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
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
#! /usr/bin/env bash
# SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
# SPDX-FileCopyrightText: Bradley M. Bell <bradbell@seanet.com>
# SPDX-FileContributor: 2003-25 Bradley M. Bell
# ----------------------------------------------------------------------------
set -e -u
echo $0 $*
# ----------------------------------------------------------------------------
if [ ! -e "bin/run_cmake.sh" ]
then
   echo "bin/run_cmake.sh: must be executed from its parent directory"
   exit 1
fi
# -----------------------------------------------------------------------------
# bash function that echos and executes a command
echo_eval() {
   echo $*
   eval $*
}
# -----------------------------------------------------------------------------
verbose_make='no'
standard='c++17'
m32='no'
profile_speed='no'
callgrind='no'
clang='no'
static='no'
yes_adolc='yes'
yes_colpack='yes'
yes_ipopt='yes'
yes_fadbad='yes'
yes_cppad_jit='yes'
yes_cppadcg='yes'
yes_sacado='yes'
yes_documentation='yes'
addr_t_type='int'
testvector='boost'
debug_which='debug_all'
while [ "$#" != 0 ]
do
   if [ "$1" == '--help' ]
   then
      cat << EOF
usage: bin/run_cmake.sh: \\
   [--help] \\
   [--verbose_make] \\
   [--c++11] \\
   [--m32] \\
   [--profile_speed] \\
   [--callgrind] \\
   [--clang ] \\
   [--static] \\
   [--no_adolc] \\
   [--no_colpack] \\
   [--no_ipopt] \\
   [--no_fadbad] \\
   [--no_cppad_jit] \\
   [--no_cppadcg] \\
   [--no_sacado] \\
   [--no_optional] \\
   [--no_documentation] \\
   [--addr_t_<type>] \\
   [--<package>_vector] \\
   [--debug_<which>]
The --help option just prints this message and exits.
The value <package> above must be one of: cppad, boost, eigen, or std.
The value <which> must be one of: odd, even, all, none.
The value <type> must be one of: size_t, int, unsigned_int

EOF
      exit 0
   fi
   case "$1" in

      --verbose_make)
      verbose_make='yes'
      ;;

      --c++11)
      standard='c++11'
      ;;

      --m32)
      m32='yes'
      ;;

      --profile_speed)
      profile_speed='yes'
      ;;

      --callgrind)
      callgrind='yes'
      ;;

      --clang)
      clang='yes'
      ;;

      --static)
      static='yes'
      ;;

      --no_adolc)
      yes_adolc='no'
      ;;

      --no_colpack)
      yes_colpack='no'
      ;;

      --no_ipopt)
      yes_ipopt='no'
      ;;

      --no_cppadcg)
      yes_cppadcg='no'
      ;;

      --no_cppad_jit)
      yes_cppad_jit='no'
      ;;

      --no_fadbad)
      yes_fadbad='no'
      ;;

      --no_sacado)
      yes_sacado='no'
      ;;

      --no_optional)
      yes_adolc='no'
      yes_colpack='no'
      yes_ipopt='no'
      yes_cppadcg='no'
      yes_fadbad='no'
      yes_sacado='no'
      testvector='cppad'
      ;;

      --no_documentation)
      yes_documentation='no'
      ;;

      # ----------------------------------------------------------------------
      --addr_t_size_t)
      addr_t_type='size_t'
      ;;

      --addr_t_int)
      addr_t_type='int'
      ;;

      --addr_t_unsigned_int)
      addr_t_type='unsigned int'
      ;;

      # ----------------------------------------------------------------------
      --cppad_vector)
      testvector='cppad'
      ;;

      --boost_vector)
      testvector='boost'
      ;;

      --eigen_vector)
      testvector='eigen'
      ;;

      --std_vector)
      testvector='std'
      ;;

      # ----------------------------------------------------------------------
      --debug_odd)
      debug_which='debug_odd'
      ;;

      --debug_even)
      debug_which='debug_even'
      ;;

      --debug_all)
      debug_which='debug_all'
      ;;

      --debug_none)
      debug_which='debug_none'
      ;;

      # ----------------------------------------------------------------------
      *)
      echo "$1 is an invalid option, try bin/run_cmake.sh --help"
      exit 1
   esac
   shift
done
if [ "$standard" == 'c++11' ]
then
   # Scacdo cannot be used with c++11
   if [ "$yes_sacado" == 'yes' ]
   then
      echo 'Cannot use sacado with c++11'
      exit 1
   fi
fi
# -----------------------------------------------------------------------------
# prefix
eval `grep '^prefix=' bin/get_optional.sh`
if [[ "$prefix" =~ ^[^/] ]]
then
   prefix="$(pwd)/$prefix"
fi
echo "prefix=$prefix"
# -----------------------------------------------------------------------------
# PKG_CONFIG_PATH
PKG_CONFIG_PATH="$prefix/share/pkgconfig"
for libdir in lib lib64
do
   PKG_CONFIG_PATH+=":$prefix/$libdir/pkgconfig"
done
export PKG_CONFIG_PATH
# ---------------------------------------------------------------------------
if [ ! -e build ]
then
   echo_eval mkdir build
fi
echo_eval cd build
for name in CMakeCache.txt build.ninja Makefile
do
   if [ -e $name ]
   then
      echo_eval rm -r $name
   fi
done
# -----------------------------------------------------------------------------
# clean all variables in cmake cache
cmake_args='-U .+ -D cmake_defined_ok=FALSE'
# -----------------------------------------------------------------------------
# Generator
if [ "$verbose_make" == 'yes' ]
then
   cmake_args+="  -G 'Unix Makefiles' -D CMAKE_VERBOSE_MAKEFILE=YES"
else
   cmake_args+="  -G Ninja"
fi
# -----------------------------------------------------------------------------
# cppad_prefix
cmake_args+="  -D cppad_prefix=$prefix"
#
# cmake_install_includedirs
if [ -d '/usr/include' ]
then
   cmake_args+=" -D cmake_install_includedirs=include"
fi
#
# cmake_install_datadir
if [ -d '/usr/share' ]
then
   cmake_args+=" -D cmake_install_datadir=share"
fi
#
# cmake_install_docdir
if [ -d '/usr/share' ] && [ "$yes_documentation" == 'yes' ]
then
   cmake_args+=" -D cmake_install_docdir=share/doc"
   cmake_args+=" -D include_doc=true"
fi
#
# cmake_install_libdirs
if [ -d '/usr/lib64' ]
then
   cmake_args+=" -D cmake_install_libdirs='lib64;lib'"
elif [ -d '/usr/lib' ]
then
   cmake_args+=" -D cmake_install_libdirs='lib;lib64'"
fi
#
# {package}_prefix
prefix_list=''
include_list=''
if [ "$yes_cppadcg" == 'yes' ]
then
   if [ ! -e "$prefix/include/cppad/cg/cg.hpp" ]
   then
      echo "Cannot find $prefix/include/cppad/cg/cg.hpp"
      exit 1
   fi
   include_list+=" cppadcg"
fi
if [ "$yes_fadbad" == 'yes' ]
then
   if [ ! -e "$prefix/include/FADBAD++/badiff.h" ]
   then
      echo "Cannot find $prefix/include/FADBAD++/badiff.h"
      exit 1
   fi
   prefix_list+=" fadbad"
fi
if [ "$yes_adolc" == 'yes' ]
then
   if [ ! -d "$prefix/include/adolc" ]
   then
      echo "Cannot file $prefix/include/adolc"
      exit 1
   fi
   include_list+=" adolc"
fi
if [ "$yes_colpack" == 'yes' ]
then
   if [ ! -e "$prefix/include/ColPack" ]
   then
      echo "Cannot find $prefix/include/ColPack"
      exit 1
   fi
   prefix_list+=" colpack"
fi
if [ "$yes_ipopt" == 'yes' ]
then
   if [ ! -e "$prefix/include/coin-or/IpNLP.hpp" ]
   then
      echo "Cannot find $prefix/include/coin-or/IpoptConfig.hpp"
      exit 1
   fi
   include_list+=" ipopt"
fi
if [ "$yes_sacado" == 'yes' ]
then
   if [ ! -e "$prefix/include/Sacado_config.h" ]
   then
      echo "Cannot find $prefix/include/Sacado_config.h"
      exit
   fi
   prefix_list+=" sacado"
fi
for package in $include_list
do
   cmake_args+=" -D include_${package}=true"
done
for package in $prefix_list
do
   cmake_args+="  -D ${package}_prefix=$prefix"
done
#
# cppad_link_flags
if [ "$m32" == 'yes' ]
then
   cmake_args+=" -D cppad_link_flags=-m32"
fi
#
# cppad_cxx_flags
if [ "$m32" == 'yes' ]
then
   cppad_cxx_flags="-std=$standard -m32"
else
   cppad_cxx_flags="-std=$standard"
fi
cppad_cxx_flags+=' -Wall -pedantic-errors -Wshadow'
cppad_cxx_flags+=' -Wfloat-conversion -Wconversion'
if [ "$debug_which" == 'debug_all' ]
then
   # CMAKE_CXX_FLAGS_DEBUG include -g so do not need it here
   cppad_cxx_flags+=" -O0"
elif [ "$callgrind" == 'yes' ]
then
   # This is a quote from the Callgrind manual:
   # 'As with Cachegrind, you probably want to compile with debugging info
   # (the -g option) and with optimization turned on.'
   cppad_cxx_flags+=" -g"
fi
if [ "$(uname)" == 'Darwin' ]
then
   if which brew > /dev/null
   then
      cppad_cxx_flags+=" -I $(brew --prefix)/include"
   fi
fi
#
# cmake_args
cmake_args+=" -D cppad_cxx_flags='$cppad_cxx_flags'"
#
# clang
if [ "$clang" == 'yes' ]
then
   cmake_args+=" -D CMAKE_C_COMPILER=clang"
   cmake_args+=" -D CMAKE_CXX_COMPILER=clang++"
fi
#
# static
if [ "$static" == 'yes' ]
then
   cmake_args+=" -D cppad_static_lib=true"
fi
#
# profile
if [ "$profile_speed" == 'yes' ]
then
   cmake_args+=" -D cppad_profile_flag=-pg"
fi
#
# debug_and_release
if [ "$debug_which" == 'debug_none' ] || [ "$debug_which" == 'debug_all' ]
then
   cmake_args+=" -D cppad_debug_and_release=false"
fi
#
# simple options
cmake_args+=" -D cppad_testvector=$testvector"
cmake_args+=" -D cppad_debug_which=$debug_which"
cmake_args+=" -D cppad_max_num_threads=48"
cmake_args+=" -D cppad_tape_id_type='$addr_t_type'"
cmake_args+=" -D cppad_tape_addr_type='$addr_t_type'"
#
echo_eval cmake $cmake_args ..
#
# ----------------------------------------------------------------------------
echo "$0: OK"
exit 0