-
Notifications
You must be signed in to change notification settings - Fork 118
/
SundialsBuildOptionsPre.cmake
335 lines (260 loc) · 12.6 KB
/
SundialsBuildOptionsPre.cmake
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
# ---------------------------------------------------------------
# Programmer(s): Cody J. Balos @ LLNL
# ---------------------------------------------------------------
# SUNDIALS Copyright Start
# Copyright (c) 2002-2024, Lawrence Livermore National Security
# and Southern Methodist University.
# All rights reserved.
#
# See the top-level LICENSE and NOTICE files for details.
#
# SPDX-License-Identifier: BSD-3-Clause
# SUNDIALS Copyright End
# ---------------------------------------------------------------
# SUNDIALS build options that are interepreted prior to any
# other CMake configuration.
# ---------------------------------------------------------------
# ---------------------------------------------------------------
# xSDK specific options and defaults
# ---------------------------------------------------------------
# always show the option to turn on xSDK defaults
sundials_option(USE_XSDK_DEFAULTS BOOL "Enable default xSDK settings" OFF)
if(USE_XSDK_DEFAULTS)
message(STATUS "Enabling xSDK defaults:")
endif()
# ---------------------------------------------------------------
# Option to specify precision (sunrealtype)
# ---------------------------------------------------------------
set(DOCSTR "single, double, or extended")
sundials_option(SUNDIALS_PRECISION STRING "${DOCSTR}" "DOUBLE")
string(TOUPPER ${SUNDIALS_PRECISION} _upper_SUNDIALS_PRECISION)
force_variable(SUNDIALS_PRECISION STRING "${DOCSTR}" ${_upper_SUNDIALS_PRECISION})
# ---------------------------------------------------------------
# Option to specify index type
# ---------------------------------------------------------------
# set the index size, SUNDIALS_INDEX_SIZE defaults to 64
set(DOCSTR "Signed 64-bit (64) or signed 32-bit (32) integer")
if(USE_XSDK_DEFAULTS)
sundials_option(SUNDIALS_INDEX_SIZE STRING "${DOCSTR}" "32")
else()
sundials_option(SUNDIALS_INDEX_SIZE STRING "${DOCSTR}" "64")
endif()
set(DOCSTR "Integer type to use for indices in SUNDIALS")
sundials_option(SUNDIALS_INDEX_TYPE STRING "${DOCSTR}" "" ADVANCED)
# ---------------------------------------------------------------
# Option to enable monitoring
# ---------------------------------------------------------------
set(DOCSTR "Build with simulation monitoring capabilities enabled")
sundials_option(SUNDIALS_BUILD_WITH_MONITORING BOOL "${DOCSTR}" OFF)
# ---------------------------------------------------------------
# Option to enable profiling
# ---------------------------------------------------------------
set(DOCSTR "Build with simulation profiling capabilities enabled")
sundials_option(SUNDIALS_BUILD_WITH_PROFILING BOOL "${DOCSTR}" OFF)
if(SUNDIALS_BUILD_WITH_PROFILING)
message(WARNING "SUNDIALS built with profiling turned on, performance may be affected.")
endif()
# ---------------------------------------------------------------
# Option to enable/disable error checking
# ---------------------------------------------------------------
if(CMAKE_BUILD_TYPE MATCHES "Release|RelWithDebInfo")
set(_default_err_checks OFF)
else()
set(_default_err_checks ON)
endif()
set(DOCSTR "Build with error checking enabled/disabled. Enabling error checks may affect performance.")
sundials_option(SUNDIALS_ENABLE_ERROR_CHECKS BOOL "${DOCSTR}" ${_default_err_checks})
if(SUNDIALS_ENABLE_ERROR_CHECKS)
message(STATUS "SUNDIALS error checking enabled")
message(WARNING "SUNDIALS is being built with extensive error checks, performance may be affected.")
endif()
# ---------------------------------------------------------------
# Option to enable logging
# ---------------------------------------------------------------
set(DOCSTR "Build with logging capabilities enabled (0 = no logging, 1 = errors, 2 = +warnings, 3 = +info, 4 = +debug, 5 = +extras")
sundials_option(SUNDIALS_LOGGING_LEVEL STRING "${DOCSTR}" 2
OPTIONS "0;1;2;3;4;5")
if(SUNDIALS_LOGGING_LEVEL GREATER_EQUAL 3)
message(STATUS "SUNDIALS logging level set to ${SUNDIALS_LOGGING_LEVEL}")
message(WARNING "SUNDIALS built with additional logging turned on, performance may be affected.")
endif()
# ---------------------------------------------------------------
# Option to set the math library
# ---------------------------------------------------------------
if(UNIX)
sundials_option(SUNDIALS_MATH_LIBRARY PATH "Which math library (e.g., libm) to link to" "-lm" ADVANCED)
else()
sundials_option(SUNDIALS_MATH_LIBRARY PATH "Which math library (e.g., libm) to link to" "" ADVANCED)
endif()
# all executables will be linked against the math library
set(EXE_EXTRA_LINK_LIBS "${SUNDIALS_MATH_LIBRARY}")
# ---------------------------------------------------------------
# Options to enable static and/or shared libraries
# ---------------------------------------------------------------
sundials_option(BUILD_STATIC_LIBS BOOL "Build static libraries" ON)
sundials_option(BUILD_SHARED_LIBS BOOL "Build shared libraries" ON)
# Make sure we build at least one type of libraries
if(NOT BUILD_STATIC_LIBS AND NOT BUILD_SHARED_LIBS)
message(FATAL_ERROR "Both static and shared library generation were disabled.")
endif()
# ---------------------------------------------------------------
# Options to enable SUNDIALS packages and modules
# ---------------------------------------------------------------
# For each SUNDIALS package available (i.e. for which we have the
# sources), give the user the option of enabling/disabling it.
if(IS_DIRECTORY "${SUNDIALS_SOURCE_DIR}/src/arkode")
sundials_option(BUILD_ARKODE BOOL "Build the ARKODE library" ON)
list(APPEND SUNDIALS_BUILD_LIST "BUILD_ARKODE")
else()
set(BUILD_ARKODE OFF)
endif()
if(IS_DIRECTORY "${SUNDIALS_SOURCE_DIR}/src/cvode")
sundials_option(BUILD_CVODE BOOL "Build the CVODE library" ON)
list(APPEND SUNDIALS_BUILD_LIST "BUILD_CVODE")
else()
set(BUILD_CVODE OFF)
endif()
if(IS_DIRECTORY "${SUNDIALS_SOURCE_DIR}/src/cvodes")
sundials_option(BUILD_CVODES BOOL "Build the CVODES library" ON)
list(APPEND SUNDIALS_BUILD_LIST "BUILD_CVODES")
else()
set(BUILD_CVODES OFF)
endif()
if(IS_DIRECTORY "${SUNDIALS_SOURCE_DIR}/src/ida")
sundials_option(BUILD_IDA BOOL "Build the IDA library" ON)
list(APPEND SUNDIALS_BUILD_LIST "BUILD_IDA")
else()
set(BUILD_IDA OFF)
endif()
if(IS_DIRECTORY "${SUNDIALS_SOURCE_DIR}/src/idas")
sundials_option(BUILD_IDAS BOOL "Build the IDAS library" ON)
list(APPEND SUNDIALS_BUILD_LIST "BUILD_IDAS")
else()
set(BUILD_IDAS OFF)
endif()
if(IS_DIRECTORY "${SUNDIALS_SOURCE_DIR}/src/kinsol")
sundials_option(BUILD_KINSOL BOOL "Build the KINSOL library" ON)
list(APPEND SUNDIALS_BUILD_LIST "BUILD_KINSOL")
else()
set(BUILD_KINSOL OFF)
endif()
# ---------------------------------------------------------------
# Options to enable Fortran interfaces.
# ---------------------------------------------------------------
# Fortran 2003 interface is disabled by default
set(DOCSTR "Enable Fortran 2003 modules")
sundials_option(BUILD_FORTRAN_MODULE_INTERFACE BOOL "${DOCSTR}" OFF)
if(BUILD_FORTRAN_MODULE_INTERFACE)
# F2003 interface only supports double precision
if(NOT (SUNDIALS_PRECISION MATCHES "DOUBLE"))
message(FATAL_ERROR "F2003 interface is not compatible with ${SUNDIALS_PRECISION} precision")
endif()
# Allow a user to set where the Fortran modules will be installed
set(DOCSTR "Directory where Fortran module files are installed")
sundials_option(Fortran_INSTALL_MODDIR STRING "${DOCSTR}" "fortran")
endif()
# ---------------------------------------------------------------
# Options for benchmark suite
# ---------------------------------------------------------------
sundials_option(BUILD_BENCHMARKS BOOL "Build the SUNDIALS benchmark suite" OFF)
sundials_option(BENCHMARKS_INSTALL_PATH PATH "Output directory for installing benchmark executables" "${CMAKE_INSTALL_PREFIX}/benchmarks")
# ---------------------------------------------------------------
# Options for CMake config installation
# ---------------------------------------------------------------
set(DOCSTR "Path to SUNDIALS cmake files")
sundials_option(SUNDIALS_INSTALL_CMAKEDIR STRING "${DOCSTR}"
"${CMAKE_INSTALL_LIBDIR}/cmake/sundials")
# ---------------------------------------------------------------
# Options to enable compiler warnings, address sanitizer
# ---------------------------------------------------------------
sundials_option(ENABLE_ALL_WARNINGS BOOL
"Enable all compiler warnings" OFF ADVANCED)
sundials_option(ENABLE_WARNINGS_AS_ERRORS BOOL
"Enable compiler warnings as errors" OFF ADVANCED)
sundials_option(ENABLE_ADDRESS_SANITIZER BOOL
"Enable address sanitizer" OFF ADVANCED)
# ---------------------------------------------------------------
# Options to enable SUNDIALS debugging
# ---------------------------------------------------------------
# List of debugging options (used to add preprocessor directives)
set(_SUNDIALS_DEBUG_OPTIONS
SUNDIALS_DEBUG
SUNDIALS_DEBUG_ASSERT
SUNDIALS_DEBUG_CUDA_LASTERROR
SUNDIALS_DEBUG_HIP_LASTERROR
SUNDIALS_DEBUG_PRINTVEC)
sundials_option(SUNDIALS_DEBUG BOOL
"Enable additional debugging output and options" OFF
ADVANCED)
if(SUNDIALS_DEBUG AND SUNDIALS_LOGGING_LEVEL LESS 4)
set(DOCSTR "SUNDIALS_DEBUG=ON forced the logging level to 4")
message(STATUS "${DOCSTR}")
set(SUNDIALS_LOGGING_LEVEL "4" CACHE STRING "${DOCSTR}" FORCE)
endif()
sundials_option(SUNDIALS_DEBUG_ASSERT BOOL
"Enable assert when debugging" OFF
DEPENDS_ON SUNDIALS_DEBUG
ADVANCED)
sundials_option(SUNDIALS_DEBUG_CUDA_LASTERROR BOOL
"Enable CUDA last error checks when debugging" OFF
DEPENDS_ON SUNDIALS_DEBUG ENABLE_CUDA
ADVANCED)
sundials_option(SUNDIALS_DEBUG_HIP_LASTERROR BOOL
"Enable HIP last error checks when debugging" OFF
DEPENDS_ON SUNDIALS_DEBUG ENABLE_HIP
ADVANCED)
sundials_option(SUNDIALS_DEBUG_PRINTVEC BOOL
"Enable vector printing when debugging" OFF
DEPENDS_ON SUNDIALS_DEBUG
ADVANCED)
if(SUNDIALS_DEBUG_PRINTVEC AND SUNDIALS_LOGGING_LEVEL LESS 5)
set(DOCSTR "SUNDIALS_DEBUG_PRINTVEC=ON forced the logging level to 5")
message(STATUS "${DOCSTR}")
set(SUNDIALS_LOGGING_LEVEL "5" CACHE STRING "${DOCSTR}" FORCE)
endif()
# ---------------------------------------------------------------
# Options for SUNDIALS external
# ---------------------------------------------------------------
sundials_option(SUNDIALS_ENABLE_EXTERNAL_ADDONS BOOL
"Enables including EXTERNALLY MAINTAINED addons in the SUNDIALS build." OFF)
if(SUNDIALS_ENABLE_EXTERNAL_ADDONS)
message(WARNING "SUNDIALS_ENABLE_EXTERNAL_ADDONS=TRUE. External addons are not maintained by the SUNDIALS team. Use at your own risk.")
endif()
# ---------------------------------------------------------------
# Options for SUNDIALS testing
# ---------------------------------------------------------------
sundials_option(SUNDIALS_TEST_FLOAT_PRECISION STRING
"Precision for floating point comparisons (number of digits)" "-1" ADVANCED)
sundials_option(SUNDIALS_TEST_INTEGER_PRECISION STRING
"Precision for integer comparisons (percent difference)" "-1" ADVANCED)
sundials_option(SUNDIALS_TEST_OUTPUT_DIR PATH
"Location to write testing output files" "" ADVANCED)
sundials_option(SUNDIALS_TEST_ANSWER_DIR PATH
"Location of testing answer files" "" ADVANCED)
sundials_option(SUNDIALS_TEST_PROFILE BOOL
"Use Caliper to profile SUNDIALS tests" OFF ADVANCED)
sundials_option(SUNDIALS_TEST_NODIFF BOOL
"Disable output comparison in the regression test suite" OFF ADVANCED)
sundials_option(SUNDIALS_TEST_CONTAINER_EXE PATH
"Path to docker or podman" "" ADVANCED)
sundials_option(SUNDIALS_TEST_CONTAINER_RUN_EXTRA_ARGS STRING
"Extra arguments to pass to docker/podman run command" "--tls-verify=false" ADVANCED)
sundials_option(SUNDIALS_TEST_CONTAINER_MNT STRING
"Path to project root inside the container" "/sundials" ADVANCED)
# Include development examples in regression tests
sundials_option(SUNDIALS_TEST_DEVTESTS BOOL
"Include development tests in make test" OFF ADVANCED)
# Include unit tests in regression tests
sundials_option(SUNDIALS_TEST_UNITTESTS BOOL
"Include unit tests in make test" OFF ADVANCED)
# Include googletest unit tests in regression tests
sundials_option(SUNDIALS_TEST_ENABLE_GTEST BOOL
"Disable GTest unit tests" ON ADVANCED)
sundials_option(SUNDIALS_DEV_IWYU BOOL
"Enable include-what-you-use" OFF ADVANCED)
sundials_option(SUNDIALS_DEV_CLANG_TIDY BOOL
"Enable clang-tidy" OFF ADVANCED)
sundials_option(SUNDIALS_SCHEDULER_COMMAND STRING "Job scheduler command to use to launch SUNDIALS MPI tests" "" ADVANCED)
sundials_option(SUNDIALS_CALIPER_OUTPUT_DIR PATH "Location to write caliper output files" "" ADVANCED)
sundials_option(SUNDIALS_BENCHMARK_NUM_CPUS STRING "Number of CPU cores to run benchmarks with" "40" ADVANCED)
sundials_option(SUNDIALS_BENCHMARK_NUM_GPUS STRING "Number of GPUs to run benchmarks with" "4" ADVANCED)