forked from opencor/libopencor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
611 lines (428 loc) · 24.1 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
# Copyright libOpenCOR contributors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
cmake_minimum_required(VERSION 3.15)
project(libOpenCOR
VERSION 0.1.0)
string(TOLOWER "${CMAKE_PROJECT_NAME}" CMAKE_PROJECT_NAME_LC)
# Enable C++20.
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
# Some common CMake policies, functions, and macros.
foreach(POLICY CMP0144)
if(POLICY ${POLICY})
cmake_policy(SET ${POLICY} NEW)
endif()
endforeach()
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
include(common)
# Check whether we are meant to build our JavaScript bindings.
if(EMSCRIPTEN)
# Use a lower-case version of our project name.
string(TOLOWER "${CMAKE_PROJECT_NAME}" CMAKE_PROJECT_NAME)
# Build libOpenCOR's JavaScript bindings.
add_subdirectory(src)
else()
# On macOS, deploy on macOS 11 and later.
if(APPLE)
set(MACOS_DEPLOYMENT_TARGET 11)
if("${CMAKE_OSX_DEPLOYMENT_TARGET}" STREQUAL "")
set(CMAKE_OSX_DEPLOYMENT_TARGET ${MACOS_DEPLOYMENT_TARGET})
endif()
endif()
# Check the environment we are dealing with.
include(environmentchecks)
# Initialise/reset our available targets.
set(TARGETS "install" CACHE INTERNAL "Available targets.")
# [CMAKE_]BUILD_TYPE ==> LIBOPENCOR_BUILD_TYPE.
if(NOT IS_MULTI_CONFIG)
set(LIBOPENCOR_BUILD_TYPE_DOCSTRING "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel ...")
if(NOT "${BUILD_TYPE}" STREQUAL "")
set(LIBOPENCOR_BUILD_TYPE "${BUILD_TYPE}" CACHE STRING "${LIBOPENCOR_BUILD_TYPE_DOCSTRING}" FORCE)
elseif(NOT "${CMAKE_BUILD_TYPE}" STREQUAL "")
set(LIBOPENCOR_BUILD_TYPE "${CMAKE_BUILD_TYPE}" CACHE STRING "${LIBOPENCOR_BUILD_TYPE_DOCSTRING}")
else()
set(LIBOPENCOR_BUILD_TYPE "Debug" CACHE STRING "${LIBOPENCOR_BUILD_TYPE_DOCSTRING}")
endif()
set(CMAKE_BUILD_TYPE "${LIBOPENCOR_BUILD_TYPE}" CACHE INTERNAL "Internalise CMAKE_BUILD_TYPE, manipulate via LIBOPENCOR_BUILD_TYPE." FORCE)
endif()
unset(BUILD_TYPE CACHE)
# CODE_ANALYSIS ==> LIBOPENCOR_CODE_ANALYSIS.
if(CODE_ANALYSIS_AVAILABLE)
set(LIBOPENCOR_CODE_ANALYSIS_DOCSTRING "Enable code analysis.")
set(LIBOPENCOR_CODE_ANALYSIS OFF CACHE BOOL "${LIBOPENCOR_CODE_ANALYSIS_DOCSTRING}")
endif()
if(NOT "${CODE_ANALYSIS}" STREQUAL "" AND CODE_ANALYSIS_AVAILABLE)
set(LIBOPENCOR_CODE_ANALYSIS ${CODE_ANALYSIS} CACHE BOOL "${LIBOPENCOR_CODE_ANALYSIS_DOCSTRING}" FORCE)
elseif(CODE_ANALYSIS)
message(SEND_ERROR "${CODE_ANALYSIS_ERROR_MESSAGE}")
endif()
unset(CODE_ANALYSIS CACHE)
# CODE_COVERAGE ==> LIBOPENCOR_CODE_COVERAGE.
if(CODE_COVERAGE_AVAILABLE)
set(LIBOPENCOR_CODE_COVERAGE_DOCSTRING "Enable code coverage testing.")
set(LIBOPENCOR_CODE_COVERAGE OFF CACHE BOOL "${LIBOPENCOR_CODE_COVERAGE_DOCSTRING}")
endif()
if(NOT "${CODE_COVERAGE}" STREQUAL "" AND CODE_COVERAGE_AVAILABLE)
set(LIBOPENCOR_CODE_COVERAGE ${CODE_COVERAGE} CACHE BOOL "${LIBOPENCOR_CODE_COVERAGE_DOCSTRING}" FORCE)
elseif(CODE_COVERAGE)
message(SEND_ERROR "${CODE_COVERAGE_ERROR_MESSAGE}")
endif()
unset(CODE_COVERAGE CACHE)
# COMPILER_CACHING ==> LIBOPENCOR_COMPILER_CACHING.
if(COMPILER_CACHING_AVAILABLE)
set(LIBOPENCOR_COMPILER_CACHING_DOCSTRING "Enable compiler caching.")
set(LIBOPENCOR_COMPILER_CACHING ON CACHE BOOL "${LIBOPENCOR_COMPILER_CACHING_DOCSTRING}")
endif()
if(NOT "${COMPILER_CACHING}" STREQUAL "" AND COMPILER_CACHING_AVAILABLE)
set(LIBOPENCOR_COMPILER_CACHING ${COMPILER_CACHING} CACHE BOOL "${LIBOPENCOR_COMPILER_CACHING_DOCSTRING}" FORCE)
elseif(COMPILER_CACHING)
message(SEND_ERROR "${COMPILER_CACHING_ERROR_MESSAGE}")
endif()
unset(COMPILER_CACHING CACHE)
# DOCUMENTATION ==> LIBOPENCOR_DOCUMENTATION.
if(DOCUMENTATION_AVAILABLE)
set(LIBOPENCOR_DOCUMENTATION_DOCSTRING "Generate the documentation.")
set(LIBOPENCOR_DOCUMENTATION ON CACHE BOOL "${LIBOPENCOR_DOCUMENTATION_DOCSTRING}")
endif()
if(NOT "${DOCUMENTATION}" STREQUAL "" AND DOCUMENTATION_AVAILABLE)
set(LIBOPENCOR_DOCUMENTATION ${DOCUMENTATION} CACHE BOOL "${LIBOPENCOR_DOCUMENTATION_DOCSTRING}" FORCE)
elseif(DOCUMENTATION)
message(SEND_ERROR "${DOCUMENTATION_AVAILABLE_ERROR_MESSAGE}")
endif()
unset(DOCUMENTATION CACHE)
# [CMAKE_]INSTALL_PREFIX ==> LIBOPENCOR_INSTALL_PREFIX.
set(LIBOPENCOR_INSTALL_PREFIX_DOCSTRING "Install path prefix, prepended onto install directories.")
if(NOT "${INSTALL_PREFIX}" STREQUAL "")
set(LIBOPENCOR_INSTALL_PREFIX "${INSTALL_PREFIX}" CACHE PATH "${LIBOPENCOR_INSTALL_PREFIX_DOCSTRING}" FORCE)
elseif(NOT "${CMAKE_INSTALL_PREFIX}" STREQUAL "")
set(LIBOPENCOR_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}" CACHE STRING "${LIBOPENCOR_INSTALL_PREFIX_DOCSTRING}")
else()
set(LIBOPENCOR_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}" CACHE PATH "${LIBOPENCOR_INSTALL_PREFIX_DOCSTRING}")
endif()
file(TO_CMAKE_PATH "${LIBOPENCOR_INSTALL_PREFIX}" CMAKE_INSTALL_PREFIX_PATH)
set(CMAKE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX_PATH}" CACHE INTERNAL "Internalise CMAKE_INSTALL_PREFIX, manipulate via LIBOPENCOR_INSTALL_PREFIX.")
unset(INSTALL_PREFIX CACHE)
# JAVASCRIPT_BINDINGS ==> LIBOPENCOR_JAVASCRIPT_BINDINGS.
if(JAVASCRIPT_BINDINGS_AVAILABLE)
set(LIBOPENCOR_JAVASCRIPT_BINDINGS_DOCSTRING "Build JAVASCRIPT bindings.")
set(LIBOPENCOR_JAVASCRIPT_BINDINGS OFF CACHE BOOL "${LIBOPENCOR_JAVASCRIPT_BINDINGS_DOCSTRING}")
endif()
if(NOT "${JAVASCRIPT_BINDINGS}" STREQUAL "" AND JAVASCRIPT_BINDINGS_AVAILABLE)
set(LIBOPENCOR_JAVASCRIPT_BINDINGS ${JAVASCRIPT_BINDINGS} CACHE BOOL "${LIBOPENCOR_JAVASCRIPT_BINDINGS_DOCSTRING}" FORCE)
elseif(JAVASCRIPT_BINDINGS)
message(SEND_ERROR "${JAVASCRIPT_BINDINGS_ERROR_MESSAGE}")
endif()
unset(JAVASCRIPT_BINDINGS CACHE)
# JAVASCRIPT_UNIT_TESTING ==> LIBOPENCOR_JAVASCRIPT_UNIT_TESTING.
if(JAVASCRIPT_BINDINGS_AVAILABLE)
if(JAVASCRIPT_UNIT_TESTING_AVAILABLE)
set(LIBOPENCOR_JAVASCRIPT_UNIT_TESTING_DOCSTRING "Enable JAVASCRIPT unit testing.")
set(LIBOPENCOR_JAVASCRIPT_UNIT_TESTING ${LIBOPENCOR_JAVASCRIPT_BINDINGS} CACHE BOOL "${LIBOPENCOR_JAVASCRIPT_UNIT_TESTING_DOCSTRING}")
endif()
if(NOT "${JAVASCRIPT_UNIT_TESTING}" STREQUAL "" AND JAVASCRIPT_UNIT_TESTING_AVAILABLE)
set(LIBOPENCOR_JAVASCRIPT_UNIT_TESTING ${JAVASCRIPT_UNIT_TESTING} CACHE BOOL "${LIBOPENCOR_JAVASCRIPT_UNIT_TESTING_DOCSTRING}" FORCE)
elseif(JAVASCRIPT_UNIT_TESTING)
message(SEND_ERROR "${JAVASCRIPT_UNIT_TESTING_ERROR_MESSAGE}")
endif()
unset(JAVASCRIPT_UNIT_TESTING CACHE)
endif()
# MEMORY_CHECKS ==> LIBOPENCOR_MEMORY_CHECKS.
if(MEMORY_CHECKS_AVAILABLE)
set(LIBOPENCOR_MEMORY_CHECKS_DOCSTRING "Enable memory checks.")
set(LIBOPENCOR_MEMORY_CHECKS OFF CACHE BOOL "${LIBOPENCOR_MEMORY_CHECKS_DOCSTRING}")
endif()
if(NOT "${MEMORY_CHECKS}" STREQUAL "" AND MEMORY_CHECKS_AVAILABLE)
set(LIBOPENCOR_MEMORY_CHECKS ${MEMORY_CHECKS} CACHE BOOL "${LIBOPENCOR_MEMORY_CHECKS_DOCSTRING}" FORCE)
elseif(MEMORY_CHECKS)
message(SEND_ERROR "${MEMORY_CHECKS_ERROR_MESSAGE}")
endif()
unset(MEMORY_CHECKS CACHE)
# PREBUILT_LIBCELLML ==> LIBOPENCOR_PREBUILT_LIBCELLML.
set(LIBOPENCOR_PREBUILT_LIBCELLML_DOCSTRING "Use the prebuilt version of libCellML.")
set(LIBOPENCOR_PREBUILT_LIBCELLML ON CACHE BOOL "${LIBOPENCOR_PREBUILT_LIBCELLML_DOCSTRING}")
if(NOT "${PREBUILT_LIBCELLML}" STREQUAL "")
set(LIBOPENCOR_PREBUILT_LIBCELLML ${PREBUILT_LIBCELLML} CACHE BOOL "${LIBOPENCOR_PREBUILT_LIBCELLML_DOCSTRING}" FORCE)
endif()
unset(PREBUILT_LIBCELLML CACHE)
# PREBUILT_LIBCOMBINE ==> LIBOPENCOR_PREBUILT_LIBCOMBINE.
set(LIBOPENCOR_PREBUILT_LIBCOMBINE_DOCSTRING "Use the prebuilt version of libCOMBINE.")
set(LIBOPENCOR_PREBUILT_LIBCOMBINE ON CACHE BOOL "${LIBOPENCOR_PREBUILT_LIBCOMBINE_DOCSTRING}")
if(NOT "${PREBUILT_LIBCOMBINE}" STREQUAL "")
set(LIBOPENCOR_PREBUILT_LIBCOMBINE ${PREBUILT_LIBCOMBINE} CACHE BOOL "${LIBOPENCOR_PREBUILT_LIBCOMBINE_DOCSTRING}" FORCE)
endif()
unset(PREBUILT_LIBCOMBINE CACHE)
# PREBUILT_LIBCURL ==> LIBOPENCOR_PREBUILT_LIBCURL.
set(LIBOPENCOR_PREBUILT_LIBCURL_DOCSTRING "Use the prebuilt version of libcurl.")
set(LIBOPENCOR_PREBUILT_LIBCURL ON CACHE BOOL "${LIBOPENCOR_PREBUILT_LIBCURL_DOCSTRING}")
if(NOT "${PREBUILT_LIBCURL}" STREQUAL "")
set(LIBOPENCOR_PREBUILT_LIBCURL ${PREBUILT_LIBCURL} CACHE BOOL "${LIBOPENCOR_PREBUILT_LIBCURL_DOCSTRING}" FORCE)
endif()
unset(PREBUILT_LIBCURL CACHE)
# PREBUILT_LIBNUML ==> LIBOPENCOR_PREBUILT_LIBNUML.
set(LIBOPENCOR_PREBUILT_LIBNUML_DOCSTRING "Use the prebuilt version of libNuML.")
set(LIBOPENCOR_PREBUILT_LIBNUML ON CACHE BOOL "${LIBOPENCOR_PREBUILT_LIBNUML_DOCSTRING}")
if(NOT "${PREBUILT_LIBNUML}" STREQUAL "")
set(LIBOPENCOR_PREBUILT_LIBNUML ${PREBUILT_LIBNUML} CACHE BOOL "${LIBOPENCOR_PREBUILT_LIBNUML_DOCSTRING}" FORCE)
endif()
unset(PREBUILT_LIBNUML CACHE)
# PREBUILT_LIBSBML ==> LIBOPENCOR_PREBUILT_LIBSBML.
set(LIBOPENCOR_PREBUILT_LIBSBML_DOCSTRING "Use the prebuilt version of libSBML.")
set(LIBOPENCOR_PREBUILT_LIBSBML ON CACHE BOOL "${LIBOPENCOR_PREBUILT_LIBSBML_DOCSTRING}")
if(NOT "${PREBUILT_LIBSBML}" STREQUAL "")
set(LIBOPENCOR_PREBUILT_LIBSBML ${PREBUILT_LIBSBML} CACHE BOOL "${LIBOPENCOR_PREBUILT_LIBSBML_DOCSTRING}" FORCE)
endif()
unset(PREBUILT_LIBSBML CACHE)
# PREBUILT_LIBSEDML ==> LIBOPENCOR_PREBUILT_LIBSEDML.
set(LIBOPENCOR_PREBUILT_LIBSEDML_DOCSTRING "Use the prebuilt version of libSEDML.")
set(LIBOPENCOR_PREBUILT_LIBSEDML ON CACHE BOOL "${LIBOPENCOR_PREBUILT_LIBSEDML_DOCSTRING}")
if(NOT "${PREBUILT_LIBSEDML}" STREQUAL "")
set(LIBOPENCOR_PREBUILT_LIBSEDML ${PREBUILT_LIBSEDML} CACHE BOOL "${LIBOPENCOR_PREBUILT_LIBSEDML_DOCSTRING}" FORCE)
endif()
unset(PREBUILT_LIBSEDML CACHE)
# PREBUILT_LIBSSH2 ==> LIBOPENCOR_PREBUILT_LIBSSH2.
set(LIBOPENCOR_PREBUILT_LIBSSH2_DOCSTRING "Use the prebuilt version of libssh2.")
set(LIBOPENCOR_PREBUILT_LIBSSH2 ON CACHE BOOL "${LIBOPENCOR_PREBUILT_LIBSSH2_DOCSTRING}")
if(NOT "${PREBUILT_LIBSSH2}" STREQUAL "")
set(LIBOPENCOR_PREBUILT_LIBSSH2 ${PREBUILT_LIBSSH2} CACHE BOOL "${LIBOPENCOR_PREBUILT_LIBSSH2_DOCSTRING}" FORCE)
endif()
unset(PREBUILT_LIBSSH2 CACHE)
# PREBUILT_LIBXML2 ==> LIBOPENCOR_PREBUILT_LIBXML2.
set(LIBOPENCOR_PREBUILT_LIBXML2_DOCSTRING "Use the prebuilt version of libxml2.")
set(LIBOPENCOR_PREBUILT_LIBXML2 ON CACHE BOOL "${LIBOPENCOR_PREBUILT_LIBXML2_DOCSTRING}")
if(NOT "${PREBUILT_LIBXML2}" STREQUAL "")
set(LIBOPENCOR_PREBUILT_LIBXML2 ${PREBUILT_LIBXML2} CACHE BOOL "${LIBOPENCOR_PREBUILT_LIBXML2_DOCSTRING}" FORCE)
endif()
unset(PREBUILT_LIBXML2 CACHE)
# PREBUILT_LLVMCLANG ==> LIBOPENCOR_PREBUILT_LLVMCLANG.
set(LIBOPENCOR_PREBUILT_LLVMCLANG_DOCSTRING "Use the prebuilt version of LLVM+Clang.")
set(LIBOPENCOR_PREBUILT_LLVMCLANG ON CACHE BOOL "${LIBOPENCOR_PREBUILT_LLVMCLANG_DOCSTRING}")
if(NOT "${PREBUILT_LLVMCLANG}" STREQUAL "")
set(LIBOPENCOR_PREBUILT_LLVMCLANG ${PREBUILT_LLVMCLANG} CACHE BOOL "${LIBOPENCOR_PREBUILT_LLVMCLANG_DOCSTRING}" FORCE)
endif()
unset(PREBUILT_LLVMCLANG CACHE)
# PREBUILT_OPENSSL ==> LIBOPENCOR_PREBUILT_OPENSSL.
set(LIBOPENCOR_PREBUILT_OPENSSL_DOCSTRING "Use the prebuilt version of OpenSSL.")
set(LIBOPENCOR_PREBUILT_OPENSSL ON CACHE BOOL "${LIBOPENCOR_PREBUILT_OPENSSL_DOCSTRING}")
if(NOT "${PREBUILT_OPENSSL}" STREQUAL "")
set(LIBOPENCOR_PREBUILT_OPENSSL ${PREBUILT_OPENSSL} CACHE BOOL "${LIBOPENCOR_PREBUILT_OPENSSL_DOCSTRING}" FORCE)
endif()
unset(PREBUILT_OPENSSL CACHE)
# PREBUILT_SUNDIALS ==> LIBOPENCOR_PREBUILT_SUNDIALS.
set(LIBOPENCOR_PREBUILT_SUNDIALS_DOCSTRING "Use the prebuilt version of SUNDIALS.")
set(LIBOPENCOR_PREBUILT_SUNDIALS ON CACHE BOOL "${LIBOPENCOR_PREBUILT_SUNDIALS_DOCSTRING}")
if(NOT "${PREBUILT_SUNDIALS}" STREQUAL "")
set(LIBOPENCOR_PREBUILT_SUNDIALS ${PREBUILT_SUNDIALS} CACHE BOOL "${LIBOPENCOR_PREBUILT_SUNDIALS_DOCSTRING}" FORCE)
endif()
unset(PREBUILT_SUNDIALS CACHE)
# PREBUILT_ZIPPER ==> LIBOPENCOR_PREBUILT_ZIPPER.
set(LIBOPENCOR_PREBUILT_ZIPPER_DOCSTRING "Use the prebuilt version of zipper.")
set(LIBOPENCOR_PREBUILT_ZIPPER ON CACHE BOOL "${LIBOPENCOR_PREBUILT_ZIPPER_DOCSTRING}")
if(NOT "${PREBUILT_ZIPPER}" STREQUAL "")
set(LIBOPENCOR_PREBUILT_ZIPPER ${PREBUILT_ZIPPER} CACHE BOOL "${LIBOPENCOR_PREBUILT_ZIPPER_DOCSTRING}" FORCE)
endif()
unset(PREBUILT_ZIPPER CACHE)
# PREBUILT_ZLIB ==> LIBOPENCOR_PREBUILT_ZLIB.
set(LIBOPENCOR_PREBUILT_ZLIB_DOCSTRING "Use the prebuilt version of zlib.")
set(LIBOPENCOR_PREBUILT_ZLIB ON CACHE BOOL "${LIBOPENCOR_PREBUILT_ZLIB_DOCSTRING}")
if(NOT "${PREBUILT_ZLIB}" STREQUAL "")
set(LIBOPENCOR_PREBUILT_ZLIB ${PREBUILT_ZLIB} CACHE BOOL "${LIBOPENCOR_PREBUILT_ZLIB_DOCSTRING}" FORCE)
endif()
unset(PREBUILT_ZLIB CACHE)
# PYTHON_BINDINGS ==> LIBOPENCOR_PYTHON_BINDINGS.
if(PYTHON_BINDINGS_AVAILABLE)
set(LIBOPENCOR_PYTHON_BINDINGS_DOCSTRING "Build Python bindings.")
set(LIBOPENCOR_PYTHON_BINDINGS OFF CACHE BOOL "${LIBOPENCOR_PYTHON_BINDINGS_DOCSTRING}")
endif()
if(NOT "${PYTHON_BINDINGS}" STREQUAL "" AND PYTHON_BINDINGS_AVAILABLE)
set(LIBOPENCOR_PYTHON_BINDINGS ${PYTHON_BINDINGS} CACHE BOOL "${LIBOPENCOR_PYTHON_BINDINGS_DOCSTRING}" FORCE)
elseif(PYTHON_BINDINGS)
message(SEND_ERROR "${PYTHON_BINDINGS_ERROR_MESSAGE}")
endif()
unset(PYTHON_BINDINGS CACHE)
# PYTHON_UNIT_TESTING ==> LIBOPENCOR_PYTHON_UNIT_TESTING.
if(PYTHON_BINDINGS_AVAILABLE)
if(PYTHON_UNIT_TESTING_AVAILABLE)
set(LIBOPENCOR_PYTHON_UNIT_TESTING_DOCSTRING "Enable Python unit testing.")
set(LIBOPENCOR_PYTHON_UNIT_TESTING ${LIBOPENCOR_PYTHON_BINDINGS} CACHE BOOL "${LIBOPENCOR_PYTHON_UNIT_TESTING_DOCSTRING}")
endif()
if(NOT "${PYTHON_UNIT_TESTING}" STREQUAL "" AND PYTHON_UNIT_TESTING_AVAILABLE)
set(LIBOPENCOR_PYTHON_UNIT_TESTING ${PYTHON_UNIT_TESTING} CACHE BOOL "${LIBOPENCOR_PYTHON_UNIT_TESTING_DOCSTRING}" FORCE)
elseif(PYTHON_UNIT_TESTING)
message(SEND_ERROR "${PYTHON_UNIT_TESTING_ERROR_MESSAGE}")
endif()
unset(PYTHON_UNIT_TESTING CACHE)
endif()
# [BUILD_]SHARED_LIBS ==> LIBOPENCOR_SHARED_LIBS.
set(LIBOPENCOR_SHARED_LIBS_DOCSTRING "Build shared libraries.")
if(NOT "${SHARED_LIBS}" STREQUAL "")
set(LIBOPENCOR_SHARED_LIBS ${SHARED_LIBS} CACHE BOOL "${LIBOPENCOR_SHARED_LIBS_DOCSTRING}" FORCE)
else()
set(LIBOPENCOR_SHARED_LIBS ON CACHE BOOL "${LIBOPENCOR_SHARED_LIBS_DOCSTRING}")
endif()
set(BUILD_SHARED_LIBS ${LIBOPENCOR_SHARED_LIBS} CACHE INTERNAL "Internalise BUILD_SHARED_LIBS, manipulate via LIBOPENCOR_SHARED_LIBS.")
unset(SHARED_LIBS CACHE)
# TARGET_ARCHITECTURE ==> LIBOPENCOR_TARGET_ARCHITECTURE.
# Note: this is only relevant on macOS since on Windows the target architecture is always going to be the same as
# that of the version of MSVC we are using (i.e. x64 or arm64) while on Linux we have no choice but to target
# the same architecture as that of the system.
if(APPLE)
set(LIBOPENCOR_TARGET_ARCHITECTURE_DOCSTRING "Specify the target architecture (Intel or ARM).")
set(LIBOPENCOR_TARGET_ARCHITECTURE ${DEFAULT_TARGET_ARCHITECTURE} CACHE STRING "${LIBOPENCOR_TARGET_ARCHITECTURE_DOCSTRING}")
if(NOT "${TARGET_ARCHITECTURE}" STREQUAL "")
set(LIBOPENCOR_TARGET_ARCHITECTURE ${TARGET_ARCHITECTURE} CACHE STRING "${LIBOPENCOR_TARGET_ARCHITECTURE_DOCSTRING}" FORCE)
endif()
unset(TARGET_ARCHITECTURE CACHE)
endif()
# UNIT_TESTING ==> LIBOPENCOR_UNIT_TESTING.
set(LIBOPENCOR_UNIT_TESTING_DOCSTRING "Enable unit testing.")
set(LIBOPENCOR_UNIT_TESTING ON CACHE BOOL "${LIBOPENCOR_UNIT_TESTING_DOCSTRING}")
if(NOT "${UNIT_TESTING}" STREQUAL "")
set(LIBOPENCOR_UNIT_TESTING ${UNIT_TESTING} CACHE BOOL "${LIBOPENCOR_UNIT_TESTING_DOCSTRING}" FORCE)
endif()
unset(UNIT_TESTING CACHE)
# WARNINGS_AS_ERRORS ==> LIBOPENCOR_WARNINGS_AS_ERRORS.
set(LIBOPENCOR_WARNINGS_AS_ERRORS_DOCSTRING "Treat warnings as errors.")
set(LIBOPENCOR_WARNINGS_AS_ERRORS ON CACHE BOOL "${LIBOPENCOR_WARNINGS_AS_ERRORS_DOCSTRING}")
if(NOT "${WARNINGS_AS_ERRORS}" STREQUAL "")
set(LIBOPENCOR_WARNINGS_AS_ERRORS ${WARNINGS_AS_ERRORS} CACHE BOOL "${LIBOPENCOR_WARNINGS_AS_ERRORS_DOCSTRING}" FORCE)
endif()
unset(WARNINGS_AS_ERRORS CACHE)
# Make sure that the configuration is sound.
if(LIBOPENCOR_CODE_COVERAGE)
if(NOT LIBOPENCOR_SHARED_LIBS)
message(SEND_ERROR "Configuration confusion: code coverage is requested which means that a static library cannot be requested.")
endif()
if(NOT LIBOPENCOR_UNIT_TESTING)
message(SEND_ERROR "Configuration confusion: code coverage is requested which means that unit testing should also be requested.")
endif()
endif()
if(LIBOPENCOR_MEMORY_CHECKS)
if("${LIBOPENCOR_BUILD_TYPE}" STREQUAL "Release")
message(SEND_ERROR "Configuration confusion: memory checks are requested which means that a release build cannot also be requested.")
endif()
if(NOT LIBOPENCOR_UNIT_TESTING)
message(SEND_ERROR "Configuration confusion: memory checks are requested which means that unit testing should also be requested.")
endif()
endif()
if(LIBOPENCOR_PYTHON_BINDINGS)
if(LIBOPENCOR_SHARED_LIBS)
message(SEND_ERROR "Configuration confusion: Python bindings are requested which means that a shared library cannot be requested.")
endif()
endif()
if(LIBOPENCOR_PYTHON_UNIT_TESTING)
if(NOT LIBOPENCOR_PYTHON_BINDINGS)
message(SEND_ERROR "Configuration confusion: Python unit testing is requested which means that Python bindings should also be requested.")
endif()
endif()
if(APPLE)
if( NOT "${LIBOPENCOR_TARGET_ARCHITECTURE}" STREQUAL "Intel"
AND NOT "${LIBOPENCOR_TARGET_ARCHITECTURE}" STREQUAL "ARM")
message(SEND_ERROR "Configuration error: unsupported target architecture (${LIBOPENCOR_TARGET_ARCHITECTURE}). Supported target architectures are Intel and ARM.")
endif()
endif()
# Determine whether we are building in release mode.
# Note: this only makes sense if we are not in a multi-configuration mode, i.e. IS_MULTI_CONFIG is equal to FALSE, which
# is likely to be the case when building a third-party library.
if(NOT "${LIBOPENCOR_BUILD_TYPE}" STREQUAL "Debug")
set(RELEASE_MODE TRUE)
endif()
# Determine whether we are building for an Intel processor.
if("${LIBOPENCOR_TARGET_ARCHITECTURE}" STREQUAL "Intel")
set(INTEL_MODE TRUE)
if(APPLE)
set(CMAKE_OSX_ARCHITECTURES x86_64)
endif()
elseif(APPLE)
set(CMAKE_OSX_ARCHITECTURES arm64)
endif()
# Build libOpenCOR.
add_subdirectory(src)
endif()
# Carry on if we are not building our JavaScript bindings and we don't only want to build some third-party libraries.
if(NOT EMSCRIPTEN AND NOT ONLY_BUILD_THIRD_PARTY_LIBRARIES)
# Enable unit testing.
if(LIBOPENCOR_UNIT_TESTING)
enable_testing()
set(BUILD_GMOCK OFF CACHE BOOL "" FORCE)
set(INSTALL_GTEST OFF CACHE BOOL "" FORCE)
add_subdirectory(extern/googletest)
mark_as_advanced(BUILD_GMOCK
GTEST_HAS_ABSL
INSTALL_GTEST)
endif()
# Run our tests.
add_subdirectory(tests)
# Generate our documentation.
add_subdirectory(doc)
# Check our code formatting and format our code.
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/cmake/formatting)
# Package libOpenCOR.
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/cmake/packaging)
# Summary of our configuration.
message(STATUS "Configuration summary:")
if(NOT "${LIBOPENCOR_BUILD_TYPE}" STREQUAL "")
message(STATUS " - LIBOPENCOR_BUILD_TYPE: ${LIBOPENCOR_BUILD_TYPE}")
endif()
if(NOT "${LIBOPENCOR_CODE_ANALYSIS}" STREQUAL "")
message(STATUS " - LIBOPENCOR_CODE_ANALYSIS: ${LIBOPENCOR_CODE_ANALYSIS}")
endif()
if(NOT "${LIBOPENCOR_CODE_COVERAGE}" STREQUAL "")
message(STATUS " - LIBOPENCOR_CODE_COVERAGE: ${LIBOPENCOR_CODE_COVERAGE}")
endif()
if(NOT "${LIBOPENCOR_COMPILER_CACHING}" STREQUAL "")
message(STATUS " - LIBOPENCOR_COMPILER_CACHING: ${LIBOPENCOR_COMPILER_CACHING}")
endif()
if(NOT "${LIBOPENCOR_DOCUMENTATION}" STREQUAL "")
message(STATUS " - LIBOPENCOR_DOCUMENTATION: ${LIBOPENCOR_DOCUMENTATION}")
endif()
message(STATUS " - LIBOPENCOR_INSTALL_PREFIX: ${LIBOPENCOR_INSTALL_PREFIX}")
if(NOT "${LIBOPENCOR_JAVASCRIPT_BINDINGS}" STREQUAL "")
message(STATUS " - LIBOPENCOR_JAVASCRIPT_BINDINGS: ${LIBOPENCOR_JAVASCRIPT_BINDINGS}")
endif()
if(NOT "${LIBOPENCOR_JAVASCRIPT_UNIT_TESTING}" STREQUAL "")
message(STATUS " - LIBOPENCOR_JAVASCRIPT_UNIT_TESTING: ${LIBOPENCOR_JAVASCRIPT_UNIT_TESTING}")
endif()
if(NOT "${LIBOPENCOR_MEMORY_CHECKS}" STREQUAL "")
message(STATUS " - LIBOPENCOR_MEMORY_CHECKS: ${LIBOPENCOR_MEMORY_CHECKS}")
endif()
message(STATUS " - LIBOPENCOR_PREBUILT_LIBCELLML: ${LIBOPENCOR_PREBUILT_LIBCELLML}")
message(STATUS " - LIBOPENCOR_PREBUILT_LIBCOMBINE: ${LIBOPENCOR_PREBUILT_LIBCOMBINE}")
message(STATUS " - LIBOPENCOR_PREBUILT_LIBCURL: ${LIBOPENCOR_PREBUILT_LIBCURL}")
message(STATUS " - LIBOPENCOR_PREBUILT_LIBNUML: ${LIBOPENCOR_PREBUILT_LIBNUML}")
message(STATUS " - LIBOPENCOR_PREBUILT_LIBSBML: ${LIBOPENCOR_PREBUILT_LIBSBML}")
message(STATUS " - LIBOPENCOR_PREBUILT_LIBSEDML: ${LIBOPENCOR_PREBUILT_LIBSEDML}")
message(STATUS " - LIBOPENCOR_PREBUILT_LIBSSH2: ${LIBOPENCOR_PREBUILT_LIBSSH2}")
message(STATUS " - LIBOPENCOR_PREBUILT_LIBXML2: ${LIBOPENCOR_PREBUILT_LIBXML2}")
message(STATUS " - LIBOPENCOR_PREBUILT_LLVMCLANG: ${LIBOPENCOR_PREBUILT_LLVMCLANG}")
message(STATUS " - LIBOPENCOR_PREBUILT_OPENSSL: ${LIBOPENCOR_PREBUILT_OPENSSL}")
message(STATUS " - LIBOPENCOR_PREBUILT_SUNDIALS: ${LIBOPENCOR_PREBUILT_SUNDIALS}")
message(STATUS " - LIBOPENCOR_PREBUILT_ZIPPER: ${LIBOPENCOR_PREBUILT_ZIPPER}")
message(STATUS " - LIBOPENCOR_PREBUILT_ZLIB: ${LIBOPENCOR_PREBUILT_ZLIB}")
if(NOT "${LIBOPENCOR_PYTHON_BINDINGS}" STREQUAL "")
message(STATUS " - LIBOPENCOR_PYTHON_BINDINGS: ${LIBOPENCOR_PYTHON_BINDINGS}")
endif()
if(NOT "${LIBOPENCOR_PYTHON_UNIT_TESTING}" STREQUAL "")
message(STATUS " - LIBOPENCOR_PYTHON_UNIT_TESTING: ${LIBOPENCOR_PYTHON_UNIT_TESTING}")
endif()
message(STATUS " - LIBOPENCOR_SHARED_LIBS: ${LIBOPENCOR_SHARED_LIBS}")
message(STATUS " - LIBOPENCOR_TARGET_ARCHITECTURE: ${LIBOPENCOR_TARGET_ARCHITECTURE}")
message(STATUS " - LIBOPENCOR_UNIT_TESTING: ${LIBOPENCOR_UNIT_TESTING}")
message(STATUS " - LIBOPENCOR_WARNINGS_AS_ERRORS: ${LIBOPENCOR_WARNINGS_AS_ERRORS}")
# Summary of our available targets.
message(STATUS "Useful targets:")
foreach(TARGET ${TARGETS})
message(STATUS " - ${TARGET}")
endforeach()
endif()