-
Notifications
You must be signed in to change notification settings - Fork 12
/
CMakeLists.txt
619 lines (564 loc) · 28.6 KB
/
CMakeLists.txt
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
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
# NOTE: the 3.18 requirement comes from here:
# https://cmake.org/cmake/help/latest/module/CheckLinkerFlag.html
cmake_minimum_required(VERSION 3.18.0)
# Set default build type to "Release".
# NOTE: this should be done before the project command since the latter can set
# CMAKE_BUILD_TYPE itself (it does so for nmake).
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release CACHE STRING
"Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel."
FORCE)
endif()
project(heyoka VERSION 7.0.0 LANGUAGES CXX C)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake" "${CMAKE_CURRENT_SOURCE_DIR}/cmake/yacma")
message(STATUS "System name: ${CMAKE_SYSTEM_NAME}")
message(STATUS "System processor: ${CMAKE_SYSTEM_PROCESSOR}")
message(STATUS "heyoka version: ${heyoka_VERSION}")
# Print some info about the long double type.
include(CheckTypeSize)
CHECK_TYPE_SIZE("long double" _HEYOKA_LONG_DOUBLE_SIZE LANGUAGE CXX)
message(STATUS "Size of the long double type: ${_HEYOKA_LONG_DOUBLE_SIZE}")
unset(_HEYOKA_LONG_DOUBLE_SIZE)
# Run the YACMA compiler setup.
include(YACMACompilerLinkerSettings)
# The build options.
option(HEYOKA_BUILD_TESTS "Build unit tests." OFF)
option(HEYOKA_BUILD_BENCHMARKS "Build benchmarks." OFF)
option(HEYOKA_BUILD_TUTORIALS "Build tutorials." OFF)
option(HEYOKA_WITH_MPPP "Enable features relying on mp++." OFF)
option(HEYOKA_WITH_SLEEF "Enable features relying on SLEEF." OFF)
option(HEYOKA_BUILD_STATIC_LIBRARY "Build heyoka as a static library, instead of dynamic." OFF)
option(HEYOKA_ENABLE_IPO "Enable IPO (requires compiler support)." OFF)
option(HEYOKA_FORCE_STATIC_LLVM "Force linking to the static version of the LLVM libraries." OFF)
mark_as_advanced(HEYOKA_FORCE_STATIC_LLVM)
option(HEYOKA_HIDE_LLVM_SYMBOLS "Try to hide LLVM symbols when linking statically to LLVM." OFF)
mark_as_advanced(HEYOKA_HIDE_LLVM_SYMBOLS)
# NOTE: on Unix systems, the correct library installation path
# could be something other than just "lib", such as "lib64",
# "lib32", etc., depending on platform/configuration. Apparently,
# CMake provides this information via the GNUInstallDirs module.
# Let's enable this for now on all Unixes except OSX.
# NOTE: potentially, this could be applicable to Cygwin as well.
#
# https://cmake.org/cmake/help/v3.15/module/GNUInstallDirs.html
# https://cmake.org/pipermail/cmake/2013-July/055375.html
if(UNIX AND NOT APPLE)
include(GNUInstallDirs)
set(_HEYOKA_INSTALL_LIBDIR_DEFAULT "${CMAKE_INSTALL_LIBDIR}")
else()
set(_HEYOKA_INSTALL_LIBDIR_DEFAULT "lib")
endif()
if(NOT HEYOKA_INSTALL_LIBDIR)
set(HEYOKA_INSTALL_LIBDIR "${_HEYOKA_INSTALL_LIBDIR_DEFAULT}" CACHE STRING
"Library installation directory." FORCE)
endif()
mark_as_advanced(HEYOKA_INSTALL_LIBDIR)
message(STATUS "Library installation directory: ${HEYOKA_INSTALL_LIBDIR}")
# Assemble the flags.
set(HEYOKA_CXX_FLAGS_DEBUG ${YACMA_CXX_FLAGS} ${YACMA_CXX_FLAGS_DEBUG})
set(HEYOKA_CXX_FLAGS_RELEASE ${YACMA_CXX_FLAGS})
if(YACMA_COMPILER_IS_MSVC)
# On both cl and clang-cl, disable the idiotic minmax macros and enable the bigobj option.
# Also, enable the WIN32_LEAN_AND_MEAN definition:
# https://stackoverflow.com/questions/11040133/what-does-defining-win32-lean-and-mean-exclude-exactly
list(APPEND HEYOKA_CXX_FLAGS_DEBUG "-DNOMINMAX" "/bigobj" "-DWIN32_LEAN_AND_MEAN")
list(APPEND HEYOKA_CXX_FLAGS_RELEASE "-DNOMINMAX" "/bigobj" "-DWIN32_LEAN_AND_MEAN")
if(YACMA_COMPILER_IS_CLANGXX)
# clang-cl emits various warnings, let's just silence them.
# NOTE: at one point in the recent past, MSVC added an options similar to GCC's isystem:
# https://blogs.msdn.microsoft.com/vcblog/2017/12/13/broken-warnings-theory/
# We probably just need to wait for this to be picked up by CMake/clang-cl. Let's
# revisit the issue in the future.
list(APPEND _HEYOKA_CLANG_CL_DISABLED_WARNINGS
"-Wno-unused-variable"
"-Wno-inconsistent-dllimport"
"-Wno-unknown-pragmas"
"-Wno-unused-parameter"
"-Wno-sign-compare"
"-Wno-deprecated-declarations"
"-Wno-deprecated-dynamic-exception-spec"
"-Wno-old-style-cast"
"-Wno-sign-conversion"
"-Wno-non-virtual-dtor"
"-Wno-deprecated"
"-Wno-shadow"
"-Wno-shorten-64-to-32"
"-Wno-reserved-id-macro"
"-Wno-undef"
"-Wno-c++98-compat-pedantic"
"-Wno-documentation-unknown-command"
"-Wno-zero-as-null-pointer-constant"
"-Wno-language-extension-token"
"-Wno-gnu-anonymous-struct"
"-Wno-nested-anon-types"
"-Wno-documentation"
"-Wno-comma"
"-Wno-nonportable-system-include-path"
"-Wno-global-constructors"
"-Wno-redundant-parens"
"-Wno-exit-time-destructors"
"-Wno-missing-noreturn"
"-Wno-switch-enum"
"-Wno-covered-switch-default"
"-Wno-float-equal"
"-Wno-double-promotion"
"-Wno-microsoft-enum-value"
"-Wno-missing-prototypes"
"-Wno-implicit-fallthrough"
"-Wno-format-nonliteral"
"-Wno-cast-qual"
"-Wno-disabled-macro-expansion"
"-Wno-unused-private-field"
"-Wno-unused-template"
"-Wno-unused-macros"
"-Wno-extra-semi-stmt"
"-Wno-c++98-compat")
list(APPEND HEYOKA_CXX_FLAGS_DEBUG ${_HEYOKA_CLANG_CL_DISABLED_WARNINGS})
list(APPEND HEYOKA_CXX_FLAGS_RELEASE ${_HEYOKA_CLANG_CL_DISABLED_WARNINGS})
unset(_HEYOKA_CLANG_CL_DISABLED_WARNINGS)
else()
# Same as above, disable some cl warnings.
list(APPEND HEYOKA_CXX_FLAGS_DEBUG "/wd4459" "/wd4127" "/wd4251" "/wd4661")
list(APPEND HEYOKA_CXX_FLAGS_RELEASE "/wd4459" "/wd4127" "/wd4251" "/wd4661")
endif()
endif()
# Mandatory dependency on LLVM.
#
# NOTE: do it early so that we can set up
# compiler flags based on the LLVM version
# if needed.
#
# NOTE: forcibly include GNUInstallDirs (even
# though we might have already included it
# earlier) in order to work around an apparent issue
# in Findzstd.cmake triggered by the LLVM config-file packages.
# See:
#
# https://github.com/llvm/llvm-project/issues/58558
include(GNUInstallDirs)
find_package(LLVM REQUIRED CONFIG)
if(${LLVM_VERSION_MAJOR} LESS 15 OR ${LLVM_VERSION_MAJOR} GREATER 19)
message(FATAL_ERROR "LLVM >= 15 and <= 19 is required.")
endif()
message(STATUS "LLVM definitions: ${LLVM_DEFINITIONS}")
message(STATUS "LLVM include dirs: ${LLVM_INCLUDE_DIRS}")
# List of source files.
set(HEYOKA_SRC_FILES
"${CMAKE_CURRENT_SOURCE_DIR}/src/taylor_00.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/taylor_01.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/taylor_02.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/taylor_adaptive.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/taylor_adaptive_batch.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/taylor_stream_ops.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/detail/i_data.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/nt_event.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/t_event.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/dtens.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/cfunc_class.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/continuous_output.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/var_ode_sys.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/detail/cm_utils.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/detail/event_detection.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/detail/llvm_helpers.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/detail/llvm_helpers_celmec.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/detail/dfloat.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/detail/num_utils.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/detail/num_identity.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/detail/sum_sq.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/detail/div.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/detail/sub.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/detail/vector_math.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/detail/empty_callable_s11n.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/detail/setup_variational_ics.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/detail/tm_data.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/detail/debug.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/detail/aligned_buffer.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/detail/type_traits.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/detail/get_dl_path.cpp"
# NOTE: this will be an empty file in case we are not
# building with support for real.
"${CMAKE_CURRENT_SOURCE_DIR}/src/detail/real_helpers.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/detail/validate_ode_sys.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/llvm_state.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/ensemble_propagate.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/func.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/number.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/variable.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/param.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/expression_basic.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/expression_diff.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/expression_ops.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/expression_cfunc.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/lagrangian.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/hamiltonian.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/logging.cpp"
# VSOP2013 details.
"${CMAKE_CURRENT_SOURCE_DIR}/src/detail/vsop2013/vsop2013_1_1.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/detail/vsop2013/vsop2013_1_2.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/detail/vsop2013/vsop2013_1_3.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/detail/vsop2013/vsop2013_1_4.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/detail/vsop2013/vsop2013_1_5.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/detail/vsop2013/vsop2013_1_6.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/detail/vsop2013/vsop2013_2_1.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/detail/vsop2013/vsop2013_2_2.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/detail/vsop2013/vsop2013_2_3.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/detail/vsop2013/vsop2013_2_4.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/detail/vsop2013/vsop2013_2_5.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/detail/vsop2013/vsop2013_2_6.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/detail/vsop2013/vsop2013_3_1.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/detail/vsop2013/vsop2013_3_2.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/detail/vsop2013/vsop2013_3_3.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/detail/vsop2013/vsop2013_3_4.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/detail/vsop2013/vsop2013_3_5.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/detail/vsop2013/vsop2013_3_6.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/detail/vsop2013/vsop2013_4_1.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/detail/vsop2013/vsop2013_4_2.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/detail/vsop2013/vsop2013_4_3.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/detail/vsop2013/vsop2013_4_4.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/detail/vsop2013/vsop2013_4_5.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/detail/vsop2013/vsop2013_4_6.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/detail/vsop2013/vsop2013_5_1.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/detail/vsop2013/vsop2013_5_2.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/detail/vsop2013/vsop2013_5_3.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/detail/vsop2013/vsop2013_5_4.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/detail/vsop2013/vsop2013_5_5.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/detail/vsop2013/vsop2013_5_6.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/detail/vsop2013/vsop2013_6_1.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/detail/vsop2013/vsop2013_6_2.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/detail/vsop2013/vsop2013_6_3.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/detail/vsop2013/vsop2013_6_4.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/detail/vsop2013/vsop2013_6_5.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/detail/vsop2013/vsop2013_6_6.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/detail/vsop2013/vsop2013_7_1.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/detail/vsop2013/vsop2013_7_2.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/detail/vsop2013/vsop2013_7_3.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/detail/vsop2013/vsop2013_7_4.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/detail/vsop2013/vsop2013_7_5.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/detail/vsop2013/vsop2013_7_6.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/detail/vsop2013/vsop2013_8_1.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/detail/vsop2013/vsop2013_8_2.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/detail/vsop2013/vsop2013_8_3.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/detail/vsop2013/vsop2013_8_4.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/detail/vsop2013/vsop2013_8_5.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/detail/vsop2013/vsop2013_8_6.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/detail/vsop2013/vsop2013_9_1.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/detail/vsop2013/vsop2013_9_2.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/detail/vsop2013/vsop2013_9_3.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/detail/vsop2013/vsop2013_9_4.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/detail/vsop2013/vsop2013_9_5.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/detail/vsop2013/vsop2013_9_6.cpp"
# ELP2000 details.
"${CMAKE_CURRENT_SOURCE_DIR}/src/detail/elp2000/elp2000_1_3.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/detail/elp2000/elp2000_4_9.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/detail/elp2000/elp2000_10_15.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/detail/elp2000/elp2000_16_21.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/detail/elp2000/elp2000_22_36.cpp"
# Models.
"${CMAKE_CURRENT_SOURCE_DIR}/src/model/pendulum.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/model/nbody.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/model/fixed_centres.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/model/rotating.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/model/mascon.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/model/vsop2013.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/model/elp2000.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/model/cr3bp.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/model/ffnn.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/model/cart2geo.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/model/nrlmsise00_tn.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/model/jb08_tn.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/model/sgp4.cpp"
# Callbacks.
"${CMAKE_CURRENT_SOURCE_DIR}/src/callback/angle_reducer.cpp"
# Math functions.
"${CMAKE_CURRENT_SOURCE_DIR}/src/math/kepE.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/math/kepF.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/math/kepDE.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/math/cos.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/math/exp.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/math/log.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/math/pow.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/math/sigmoid.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/math/relu.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/math/sin.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/math/sqrt.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/math/tan.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/math/asin.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/math/acos.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/math/atan.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/math/atan2.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/math/time.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/math/cosh.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/math/sinh.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/math/tanh.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/math/asinh.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/math/acosh.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/math/atanh.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/math/erf.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/math/sum.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/math/prod.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/math/constants.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/math/dfun.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/math/relational.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/math/logical.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/math/select.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/detail/string_conv.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/detail/logging_impl.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/step_callback.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/llvm_state_mem_cache.cpp"
)
if(HEYOKA_WITH_SLEEF)
# NOTE: the sleef dummy file needs to be compiled only
# if we are building with sleef support on.
set(HEYOKA_SRC_FILES
"${CMAKE_CURRENT_SOURCE_DIR}/src/detail/sleef_dummy.cpp"
"${HEYOKA_SRC_FILES}"
)
endif()
# Setup the heyoka ABI version number.
set(HEYOKA_ABI_VERSION 32)
if(HEYOKA_BUILD_STATIC_LIBRARY)
# Setup of the heyoka static library.
message(STATUS "heyoka will be built as a static library.")
add_library(heyoka STATIC "${HEYOKA_SRC_FILES}")
else()
# Setup of the heyoka shared library.
add_library(heyoka SHARED "${HEYOKA_SRC_FILES}")
set_property(TARGET heyoka PROPERTY VERSION "${HEYOKA_ABI_VERSION}.0")
set_property(TARGET heyoka PROPERTY SOVERSION ${HEYOKA_ABI_VERSION})
set_target_properties(heyoka PROPERTIES CXX_VISIBILITY_PRESET hidden)
set_target_properties(heyoka PROPERTIES VISIBILITY_INLINES_HIDDEN TRUE)
endif()
# Setup common to both the shared and static variants.
target_compile_options(heyoka PRIVATE
"$<$<CONFIG:Debug>:${HEYOKA_CXX_FLAGS_DEBUG}>"
"$<$<CONFIG:Release>:${HEYOKA_CXX_FLAGS_RELEASE}>"
"$<$<CONFIG:RelWithDebInfo>:${HEYOKA_CXX_FLAGS_RELEASE}>"
"$<$<CONFIG:MinSizeRel>:${HEYOKA_CXX_FLAGS_RELEASE}>"
)
# Ensure that C++20 is employed when both compiling and consuming heyoka.
target_compile_features(heyoka PUBLIC cxx_std_20)
# Enforce vanilla C++ when compiling heyoka.
set_property(TARGET heyoka PROPERTY CXX_EXTENSIONS NO)
target_include_directories(heyoka PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/include>
$<INSTALL_INTERFACE:include>)
# IPO setup.
if(HEYOKA_ENABLE_IPO)
include(CheckIPOSupported)
check_ipo_supported(RESULT _HEYOKA_IPO_RESULT OUTPUT _HEYOKA_IPO_OUTPUT)
if (_HEYOKA_IPO_RESULT)
message(STATUS "IPO requested and supported, enabling.")
set_property(TARGET heyoka PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE)
else()
message(STATUS "IPO requested, but it is not supported by the compiler:\n${_HEYOKA_IPO_OUTPUT}")
endif()
unset(_HEYOKA_IPO_RESULT)
unset(_HEYOKA_IPO_OUTPUT)
endif()
# Add a define to signal that we are building the library.
target_compile_definitions(heyoka PRIVATE HEYOKA_BUILD_LIBRARY)
# Define an interface target for linking to the LLVM bits.
add_library(heyoka_llvm_internal INTERFACE)
# Add the definitions required by LLVM.
target_compile_definitions(heyoka_llvm_internal INTERFACE ${LLVM_DEFINITIONS})
# On MSVC, silence std::iterator warnings coming from the LLVM headers.
if(MSVC)
target_compile_definitions(heyoka_llvm_internal INTERFACE _SILENCE_CXX17_ITERATOR_BASE_CLASS_DEPRECATION_WARNING)
endif()
# Add the LLVM include dirs.
target_include_directories(heyoka_llvm_internal SYSTEM INTERFACE ${LLVM_INCLUDE_DIRS})
if(HEYOKA_FORCE_STATIC_LLVM OR NOT TARGET LLVM)
# NOTE: static link to llvm if explicitly requested or if the
# LLVM target does *not* exist. The LLVM target, if
# it exists, consists of a single shared library.
# NOTE: this is necessary because LLVM's config-file packages
# do not look for zlib, despite linking to the ZLIB::ZLIB
# target. I think this is not necessary in shared library builds
# because zlib might be a private dependency and thus it is not
# necessary to bring it into the link chain explicitly (as the
# LLVM shared object already brings it in).
find_package(ZLIB REQUIRED)
# NOTE: these components have been determined heuristically.
set(_HEYOKA_LLVM_COMPONENTS native orcjit)
# NOTE: not sure what these two do, I copied from symengine's CMakeLists.txt.
llvm_map_components_to_libnames(_HEYOKA_LLVM_LIBS_DIRECT ${_HEYOKA_LLVM_COMPONENTS})
llvm_expand_dependencies(_HEYOKA_LLVM_LIBS ${_HEYOKA_LLVM_LIBS_DIRECT})
target_link_libraries(heyoka_llvm_internal INTERFACE ${_HEYOKA_LLVM_LIBS})
unset(_HEYOKA_LLVM_COMPONENTS)
unset(_HEYOKA_LLVM_LIBS_DIRECT)
unset(_HEYOKA_LLVM_LIBS)
set(_HEYOKA_LLVM_STATIC_LINK TRUE)
else()
# NOTE: shared linking is preferred over static if both are available and
# if HEYOKA_FORCE_STATIC_LLVM is *not* set.
target_link_libraries(heyoka_llvm_internal INTERFACE LLVM)
set(_HEYOKA_LLVM_STATIC_LINK FALSE)
endif()
# Link to LLVM privately.
# NOTE: the BUILD_INTERFACE bit is a workaround needed when building
# heyoka as a static library: in this configuration, CMake would complain
# that heyoka_llvm_internal needs to be in the export set, even if it is just
# an interface library. See the discussion here:
# https://gitlab.kitware.com/cmake/cmake/-/issues/15415
target_link_libraries(heyoka PRIVATE "$<BUILD_INTERFACE:heyoka_llvm_internal>")
if(_HEYOKA_LLVM_STATIC_LINK AND HEYOKA_HIDE_LLVM_SYMBOLS)
# NOTE: LLVM symbol hiding is done in a heuristic fashion
# by checking if the linker supports certain flags:
#
# - first we check for "-Wl,--exclude-libs,ALL", which is supported
# by the GNU linker; if this fails,
# - we check for "-Wl,-unexported_symbol", which is supported by
# OSX's ld64 linker; otherwise,
# - we don't do anything.
#
# This is not a great solution, but it works for common use cases.
# For the GNU linker, it would be better to use "-Wl,--exclude-libs"
# on all the individual LLVM libraries we are linking to, rather than
# on ALL the static libraries, but getting such a list out of CMake
# seems hard: we link directly to the _HEYOKA_LLVM_LIBS libraries,
# but these in turn bring in indirectly several other LLVM components.
include(CheckLinkerFlag)
set(CMAKE_REQUIRED_QUIET TRUE)
check_linker_flag(CXX "-Wl,--exclude-libs,ALL" _HEYOKA_LINKER_SUPPORTS_EXCLUDE_LIBS)
if(_HEYOKA_LINKER_SUPPORTS_EXCLUDE_LIBS)
message(STATUS "Adding the linker flag \"-Wl,--exclude-libs,ALL\" to hide LLVM symbols.")
target_link_options(heyoka PRIVATE "-Wl,--exclude-libs,ALL")
else()
check_linker_flag(CXX "-Wl,-unexported_symbol,dummy" _HEYOKA_LINKER_SUPPORTS_UNEXPORTED_SYMBOL)
if(_HEYOKA_LINKER_SUPPORTS_UNEXPORTED_SYMBOL)
message(STATUS "Adding the linker flag \"-Wl,-unexported_symbol\" to hide LLVM symbols.")
target_link_options(heyoka PRIVATE "-Wl,-unexported_symbol,__ZTVN4llvm*")
target_link_options(heyoka PRIVATE "-Wl,-unexported_symbol,__ZNK4llvm*")
target_link_options(heyoka PRIVATE "-Wl,-unexported_symbol,__ZN4llvm*")
target_link_options(heyoka PRIVATE "-Wl,-unexported_symbol,__ZTIN4llvm*")
target_link_options(heyoka PRIVATE "-Wl,-unexported_symbol,_LLVM*")
target_link_options(heyoka PRIVATE "-Wl,-unexported_symbol,__ZTSN4llvm*")
endif()
endif()
unset(CMAKE_REQUIRED_QUIET)
endif()
# Mandatory dependency on fmt.
set(_HEYOKA_MIN_SUPPORTED_FMT_VERSION 9)
set(_HEYOKA_MAX_SUPPORTED_FMT_VERSION 11)
find_package(fmt REQUIRED CONFIG)
if(${fmt_VERSION_MAJOR} VERSION_LESS ${_HEYOKA_MIN_SUPPORTED_FMT_VERSION} OR
${fmt_VERSION_MAJOR} VERSION_GREATER ${_HEYOKA_MAX_SUPPORTED_FMT_VERSION})
message(FATAL_ERROR "The supported fmt versions are in the range [${_HEYOKA_MIN_SUPPORTED_FMT_VERSION}, ${_HEYOKA_MAX_SUPPORTED_FMT_VERSION}], but version ${fmt_VERSION_MAJOR} was found instead.")
endif()
message(STATUS "fmt version: ${fmt_VERSION}")
target_link_libraries(heyoka PUBLIC fmt::fmt)
# Mandatory dependency on spdlog.
find_package(spdlog REQUIRED CONFIG)
target_link_libraries(heyoka PRIVATE spdlog::spdlog)
# Mandatory dependency on TBB.
find_package(TBB REQUIRED CONFIG)
target_link_libraries(heyoka PRIVATE TBB::tbb)
# Mandatory dependency on Boost.
# NOTE: need 1.69 for safe numerics.
set(_HEYOKA_MIN_BOOST_VERSION "1.69")
# NOTE: we look for Boost in CONFIG mode first, as that has become the official supported way
# of locating Boost in recent Boost/CMake versions. If we fail, we try again in
# MODULE mode as last resort.
find_package(Boost ${_HEYOKA_MIN_BOOST_VERSION} QUIET COMPONENTS serialization CONFIG)
if(NOT ${Boost_FOUND})
message(STATUS "Boost not found in CONFIG mode, retrying in MODULE mode.")
find_package(Boost ${_HEYOKA_MIN_BOOST_VERSION} QUIET MODULE COMPONENTS serialization)
endif()
if(NOT ${Boost_FOUND})
message(FATAL_ERROR "Could not locate Boost in either CONFIG or MODULE mode.")
endif()
message(STATUS "Found Boost version ${Boost_VERSION}.")
target_link_libraries(heyoka PUBLIC Boost::boost Boost::serialization)
# NOTE: quench warnings from Boost when building the library.
target_compile_definitions(heyoka PRIVATE BOOST_ALLOW_DEPRECATED_HEADERS)
# NOTE: recent versions of libcxx remove std::unary_function/std::binary_function
# (which have been deprecated since long) in C++17 mode. This breaks, e.g., hashing
# functionality on older Boost versions. See:
# https://github.com/boostorg/container_hash/issues/22
# Note that the better approach here would be to detect libcxx rather than
# just Apple, but at this time it seems like there's no easy way to detect
# the stdlib implementation/version from CMake.
if(APPLE AND Boost_VERSION VERSION_LESS "1.81.0")
# NOTE: make this a PUBLIC definition just to err on the side
# of caution.
target_compile_definitions(heyoka PUBLIC BOOST_NO_CXX98_FUNCTION_BASE)
endif()
# Optional dependency on mp++.
set(_HEYOKA_MIN_SUPPORTED_MPPP_VERSION 2)
set(_HEYOKA_MAX_SUPPORTED_MPPP_VERSION 2)
if(HEYOKA_WITH_MPPP)
find_package(mp++ REQUIRED CONFIG)
if(${mp++_VERSION_MAJOR} VERSION_LESS ${_HEYOKA_MIN_SUPPORTED_MPPP_VERSION} OR
${mp++_VERSION_MAJOR} VERSION_GREATER ${_HEYOKA_MAX_SUPPORTED_MPPP_VERSION})
message(FATAL_ERROR "The supported mp++ versions are in the range [${_HEYOKA_MIN_SUPPORTED_MPPP_VERSION}, ${_HEYOKA_MAX_SUPPORTED_MPPP_VERSION}], but version ${mp++_VERSION_MAJOR} was found instead.")
endif()
message(STATUS "mp++ version: ${mp++_VERSION}")
# NOTE: this is necessary for the serialisation of several classes.
if(NOT mp++_WITH_BOOST_S11N)
message(FATAL_ERROR "mp++ must be installed with support for Boost.serialization.")
endif()
# NOTE: needed for formatting numbers.
if(NOT mp++_WITH_FMT)
message(FATAL_ERROR "mp++ must be installed with support for fmt.")
endif()
target_link_libraries(heyoka PUBLIC mp++::mp++)
# NOTE: _HEYOKA_WITH_REAL128 is used to signal the support
# for mppp::real128 in the config-file package.
set(_HEYOKA_WITH_REAL128 ${mp++_WITH_QUADMATH})
# Similarly for mppp::real.
set(_HEYOKA_WITH_REAL ${mp++_WITH_MPFR})
else()
set(_HEYOKA_WITH_REAL128 NO)
set(_HEYOKA_WITH_REAL NO)
endif()
# Optional dependency on SLEEF.
if(HEYOKA_WITH_SLEEF)
find_package(heyoka_SLEEF REQUIRED)
target_link_libraries(heyoka PRIVATE heyoka::SLEEF)
endif()
# Configure config.hpp.
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/config.hpp.in" "${CMAKE_CURRENT_BINARY_DIR}/include/heyoka/config.hpp" @ONLY)
# Configure the doc files.
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/doc/conf.py.in" "${CMAKE_CURRENT_SOURCE_DIR}/doc/conf.py" @ONLY)
# Installation of the header files.
install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/include/heyoka" DESTINATION include)
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/include/heyoka/config.hpp" DESTINATION include/heyoka)
# Installation of the library.
install(TARGETS heyoka
EXPORT heyoka_export
LIBRARY DESTINATION "${HEYOKA_INSTALL_LIBDIR}"
ARCHIVE DESTINATION "${HEYOKA_INSTALL_LIBDIR}"
RUNTIME DESTINATION bin
)
# Setup of the CMake config file.
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/heyoka-config.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/heyoka-config.cmake" @ONLY)
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/heyoka-config.cmake"
DESTINATION "${HEYOKA_INSTALL_LIBDIR}/cmake/heyoka")
install(EXPORT heyoka_export NAMESPACE heyoka:: DESTINATION "${HEYOKA_INSTALL_LIBDIR}/cmake/heyoka")
# Take care of versioning.
include(CMakePackageConfigHelpers)
# NOTE: since we use semantic versioning, the correct setting here is SameMajorVersion: it requires equality
# in the major version, but higher minor versions will be considered compatible. So, if heyoka 2.0.0 is requested
# and 2.1.0 is found, then all is good. However, the reverse will lead to a failure.
write_basic_package_version_file("${CMAKE_CURRENT_BINARY_DIR}/heyoka-config-version.cmake" COMPATIBILITY SameMajorVersion)
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/heyoka-config-version.cmake" DESTINATION "${HEYOKA_INSTALL_LIBDIR}/cmake/heyoka")
# Cleanup.
unset(_HEYOKA_MIN_BOOST_VERSION)
unset(_HEYOKA_MIN_SUPPORTED_MPPP_VERSION)
unset(_HEYOKA_MAX_SUPPORTED_MPPP_VERSION)
unset(_HEYOKA_WITH_REAL128)
unset(_HEYOKA_WITH_REAL)
unset(_HEYOKA_LLVM_STATIC_LINK)
unset(_HEYOKA_MIN_SUPPORTED_FMT_VERSION)
unset(_HEYOKA_MAX_SUPPORTED_FMT_VERSION)
if(HEYOKA_BUILD_TESTS)
enable_testing()
add_subdirectory(test)
endif()
if(HEYOKA_BUILD_BENCHMARKS)
add_subdirectory(benchmark)
endif()
if(HEYOKA_BUILD_TUTORIALS)
add_subdirectory(tutorial)
endif()