/
CMakeLists.txt
981 lines (737 loc) · 30.9 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
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
CMAKE_MINIMUM_REQUIRED(VERSION 3.2)
# Project definition
PROJECT(OpenCOR)
# Some in-house CMake functions/macros
INCLUDE(${CMAKE_SOURCE_DIR}/cmake/common.cmake)
# Our options
OPTION(ENABLE_SAMPLE_PLUGINS "Enable the sample plugins to be built" OFF)
OPTION(ENABLE_TEST_PLUGINS "Enable the test plugins to be built" OFF)
OPTION(ENABLE_TESTS "Enable the tests to be built" OFF)
OPTION(USE_PREBUILT_LIBGIT2_PACKAGE "Use the pre-built version of the libgit2 package" ON)
OPTION(USE_PREBUILT_LIBXDIFF_PACKAGE "Use the pre-built version of the LibXDiff package" ON)
OPTION(USE_PREBUILT_LLVM_PLUGIN "Use the pre-built version of the LLVM plugin" ON)
OPTION(USE_PREBUILT_OAUTH_PACKAGE "Use the pre-built version of the OAuth package" ON)
OPTION(USE_PREBUILT_OPENSSL_PACKAGE "Use the pre-built version of the OpenSSL package" ON)
OPTION(USE_PREBUILT_QSCINTILLA_PLUGIN "Use the pre-built version of the QScintilla plugin" ON)
OPTION(USE_PREBUILT_QWT_PLUGIN "Use the pre-built version of the Qwt plugin" ON)
OPTION(USE_PREBUILT_SUNDIALS_PLUGIN "Use the pre-built version of the SUNDIALS plugin" ON)
OPTION(USE_PREBUILT_ZLIB_PACKAGE "Use the pre-built version of the zlib package" ON)
# Initialise the project
INITIALISE_PROJECT()
# Keep track of our source and build directories (needed to run our tests)
SET(SOURCE_DIRECTORY_FILENAME ${PROJECT_BUILD_DIR}/sourcedirectory.txt)
SET(BUILD_DIRECTORY_FILENAME ${PROJECT_BUILD_DIR}/builddirectory.txt)
FILE(WRITE ${SOURCE_DIRECTORY_FILENAME} "${CMAKE_SOURCE_DIR}")
FILE(WRITE ${BUILD_DIRECTORY_FILENAME} "${PROJECT_BUILD_DIR}")
KEEP_TRACK_OF_FILE(${SOURCE_DIRECTORY_FILENAME})
KEEP_TRACK_OF_FILE(${BUILD_DIRECTORY_FILENAME})
# Version/snapshot of OpenCOR
IF("${PROJECT_VERSION}" STREQUAL "")
SET(SNAPSHOT ON)
ELSE()
SET(SNAPSHOT OFF)
ENDIF()
STRING(TIMESTAMP DATE "%Y-%m-%d")
IF(SNAPSHOT)
SET(VERSION ${DATE})
ELSE()
SET(VERSION ${PROJECT_VERSION})
ENDIF()
SET(VERSION_DATE_FILENAME ${PROJECT_BUILD_DIR}/versiondate.txt)
FILE(WRITE ${VERSION_DATE_FILENAME} "${VERSION}\n${DATE}")
KEEP_TRACK_OF_FILE(${VERSION_DATE_FILENAME})
# Configure our help file
CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/doc/${CMAKE_PROJECT_NAME}.qhcp.in
${PROJECT_BUILD_DIR}/doc/${CMAKE_PROJECT_NAME}.qhcp)
# Configure our QRC files
SET(COMMON_QRC_FILENAME ${PROJECT_BUILD_DIR}/res/common.qrc)
SET(I18N_QRC_FILENAME ${PROJECT_BUILD_DIR}/res/i18n.qrc)
CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/res/common.qrc.in
${COMMON_QRC_FILENAME})
CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/res/i18n.qrc.in
${I18N_QRC_FILENAME})
# Files that make up the GUI version of OpenCOR
SET(SOURCES
src/checkforupdatesdialog.cpp
src/main.cpp
src/mainwindow.cpp
src/pluginsdialog.cpp
src/preferencesdialog.cpp
src/splashscreenwindow.cpp
src/misc/cliapplication.cpp
src/misc/cliutils.cpp
src/misc/guiapplication.cpp
src/misc/guiutils.cpp
src/plugins/cliinterface.cpp
src/plugins/coreinterface.cpp
src/plugins/datastoreinterface.cpp
src/plugins/filehandlinginterface.cpp
src/plugins/filetypeinterface.cpp
src/plugins/guiinterface.cpp
src/plugins/i18ninterface.cpp
src/plugins/plugin.cpp
src/plugins/plugininfo.cpp
src/plugins/plugininterface.cpp
src/plugins/pluginmanager.cpp
src/plugins/preferencesinterface.cpp
src/plugins/solverinterface.cpp
src/plugins/viewinterface.cpp
src/plugins/windowinterface.cpp
)
SET(HEADERS_MOC
src/checkforupdatesdialog.h
src/mainwindow.h
src/pluginsdialog.h
src/preferencesdialog.h
src/splashscreenwindow.h
src/misc/cliutils.h
src/misc/guiapplication.h
src/misc/guiutils.h
src/plugins/datastoreinterface.h
src/plugins/plugin.h
src/plugins/pluginmanager.h
src/plugins/preferencesinterface.h
src/plugins/solverinterface.h
)
SET(UIS
src/checkforupdatesdialog.ui
src/mainwindow.ui
src/pluginsdialog.ui
src/preferencesdialog.ui
src/splashscreenwindow.ui
)
SET(RESOURCES
${COMMON_QRC_FILENAME}
${I18N_QRC_FILENAME}
res/translations.qrc
res/ui.qrc
)
# Files that make up the CLI version of OpenCOR (Windows specific)
IF(WIN32)
SET(WINDOWS_CLI_SOURCES
src/misc/cliapplication.cpp
src/misc/cliutils.cpp
src/plugins/cliinterface.cpp
src/plugins/coreinterface.cpp
src/plugins/datastoreinterface.cpp
src/plugins/filehandlinginterface.cpp
src/plugins/filetypeinterface.cpp
src/plugins/plugin.cpp
src/plugins/plugininfo.cpp
src/plugins/plugininterface.cpp
src/plugins/pluginmanager.cpp
src/plugins/solverinterface.cpp
src/windows/main.cpp
)
SET(WINDOWS_CLI_HEADERS_MOC
src/misc/cliutils.h
src/plugins/datastoreinterface.h
src/plugins/plugin.h
src/plugins/pluginmanager.h
src/plugins/solverinterface.h
)
SET(WINDOWS_CLI_RESOURCES
${COMMON_QRC_FILENAME}
)
ENDIF()
# Various include directories
# Note: access to the Core plugin's source folder is needed so that we can build
# OpenCOR on its own, i.e. without any plugins (due to the global CLI/GUI
# utilities needing access to some features that are in common with the
# Core CLI/GUI utilities)...
INCLUDE_DIRECTORIES(
src/misc
src/plugins
src/plugins/miscellaneous/Core/src
)
# Update the translation (.ts) files and generate the language (.qm) files
# that will later on be embedded in the OpenCOR executable as resources
UPDATE_LANGUAGE_FILES(${CMAKE_PROJECT_NAME} ${SOURCES} ${HEADERS_MOC} ${UIS})
# Third-party library that must be directly embedded in the GUI version of
# OpenCOR
INCLUDE(src/3rdparty/QtSingleApplication/QtSingleApplication.cmake)
# Set the application icon, but only for Windows and macOS, since in the case of
# Linux, it's done through the use of app_icon (see res/ui.qrc) when we register
# our URL scheme (see MainWindow::registerOpencorUrlScheme())
# Note: on Windows, we set a bit more than just the application icon. We also
# set its product name, version, copyright, etc.
SET(PROJECT_DESCRIPTION "A cross-platform modelling environment")
IF(SNAPSHOT)
SET(FILE_VERSION 0)
SET(PRODUCT_VERSION "Snapshot ${VERSION}")
ELSE()
STRING(REPLACE "." ","
FILE_VERSION "${VERSION}")
SET(PRODUCT_VERSION "Version ${VERSION}")
ENDIF()
STRING(TIMESTAMP YEAR "%Y")
IF(WIN32)
SET(RC_FILENAME ${PROJECT_BUILD_DIR}/${CMAKE_PROJECT_NAME}.rc)
CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/res/${CMAKE_PROJECT_NAME}.rc.in
${RC_FILENAME})
LIST(APPEND SOURCES ${RC_FILENAME})
ELSEIF(APPLE)
SET(ICNS_FILENAME ${CMAKE_PROJECT_NAME}.icns)
SET(MACOSX_BUNDLE_ICON_FILE ${ICNS_FILENAME})
SET_SOURCE_FILES_PROPERTIES(res/${ICNS_FILENAME} PROPERTIES MACOSX_PACKAGE_LOCATION Resources)
LIST(APPEND SOURCES res/${ICNS_FILENAME})
ENDIF()
# Check whether tests are required and, if so, 'reset' our list of tests and set
# the destination tests directory and build our main test program
IF(ENABLE_TESTS)
# 'Reset' our list of tests
SET(TESTS_LIST_FILENAME ${PROJECT_BUILD_DIR}/tests.txt)
FILE(WRITE ${TESTS_LIST_FILENAME})
KEEP_TRACK_OF_FILE(${TESTS_LIST_FILENAME})
# Destination tests directory
# Note: DEST_TESTS_DIR isn't only used here, but also in our ADD_PLUGIN()
# macro...
IF(APPLE)
SET(DEST_TESTS_DIR ${PROJECT_BUILD_DIR}/${CMAKE_PROJECT_NAME}.app/Contents/MacOS)
ELSE()
SET(DEST_TESTS_DIR ${PROJECT_BUILD_DIR}/bin)
ENDIF()
# Build our main test program
SET(RUNTESTS_NAME runtests)
SET(TESTS_QRC_FILENAME ${PROJECT_BUILD_DIR}/src/tests/res/tests.qrc)
CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/src/tests/res/tests.qrc.in
${TESTS_QRC_FILENAME})
QT5_ADD_RESOURCES(RUNTESTS_SOURCES_RCS ${TESTS_QRC_FILENAME})
ADD_EXECUTABLE(${RUNTESTS_NAME}
src/tests/src/main.cpp
src/tests/src/testsutils.cpp
${RUNTESTS_SOURCES_RCS}
)
SET_TARGET_PROPERTIES(${RUNTESTS_NAME} PROPERTIES
OUTPUT_NAME ${RUNTESTS_NAME}
LINK_FLAGS "${LINK_FLAGS_PROPERTIES}"
)
TARGET_LINK_LIBRARIES(${RUNTESTS_NAME}
Qt5::Core
Qt5::Network
)
# Copy our main test program to our tests directory
SET(MAIN_TEST_FILENAME ${RUNTESTS_NAME}${CMAKE_EXECUTABLE_SUFFIX})
ADD_CUSTOM_COMMAND(TARGET ${RUNTESTS_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy ${PROJECT_BUILD_DIR}/${MAIN_TEST_FILENAME}
${DEST_TESTS_DIR}/${MAIN_TEST_FILENAME})
# Clean up our test program, but only if we are on macOS
IF(APPLE)
MACOS_CLEAN_UP_FILE_WITH_QT_DEPENDENCIES(${RUNTESTS_NAME} ${DEST_TESTS_DIR} ${MAIN_TEST_FILENAME})
ENDIF()
ENDIF()
# Build the OpenCOR plugins
# Note: the build order must be such that plugins needed by others are built
# first...
IF(ENABLE_SAMPLE_PLUGINS)
SET(SAMPLE_PLUGINS
sample/Sample
sample/SampleTools
sample/SampleView
sample/SampleWindow
)
ELSE()
SET(SAMPLE_PLUGINS)
ENDIF()
IF(ENABLE_TEST_PLUGINS)
SET(TEST_PLUGINS
test/ZincWindow
)
ELSE()
SET(TEST_PLUGINS)
ENDIF()
SET(PLUGINS
# Plugins that have no dependencies
api/BioSignalMLAPI
api/CellMLAPI
api/SBMLAPI
api/SEDMLAPI
miscellaneous/Core
support/StandardSupport
thirdParty/libgit2
thirdParty/LibXDiff
thirdParty/LLVM
thirdParty/OAuth
thirdParty/OpenSSL
thirdParty/QScintilla
thirdParty/Qwt
thirdParty/SUNDIALS
thirdParty/Zinc
thirdParty/zlib
# Plugins that build on top of some third-party libraries
miscellaneous/Compiler
# Plugins that provide support for some third-party libraries
support/CellMLSupport
support/QScintillaSupport
support/SEDMLSupport
support/ZIPSupport
# Plugins that provide support for some third-party libraries that have
# dependencies on others
support/COMBINESupport
# Plugins that extend some libraries (incl. third-party ones)
widget/EditorWidget
widget/GraphPanelWidget
widget/MathMLViewerWidget
widget/WebViewerWidget
widget/ZincWidget
# Plugins that provide some generic features
dataStore/DataStore
editing/EditingView
# Plugins that have dependencies on others
editing/CellMLEditingView
editing/SEDMLEditingView
support/PMRSupport
# Selectable plugins
dataStore/BioSignalMLDataStore
dataStore/CSVDataStore
editing/CellMLAnnotationView
editing/CellMLTextView
editing/RawCellMLView
editing/RawSEDMLView
editing/RawTextView
miscellaneous/HelpWindow
miscellaneous/WebBrowserWindow
organisation/FileBrowserWindow
organisation/FileOrganiserWindow
organisation/PMRWindow
organisation/PMRWorkspacesWindow
simulation/SimulationExperimentView
solver/CVODESolver
solver/ForwardEulerSolver
solver/FourthOrderRungeKuttaSolver
solver/HeunSolver
solver/IDASolver
solver/KINSOLSolver
solver/SecondOrderRungeKuttaSolver
tools/CellMLTools
# Sample and test plugins
${SAMPLE_PLUGINS}
${TEST_PLUGINS}
)
FOREACH(PLUGIN ${PLUGINS})
SET(PLUGIN_DIR src/plugins/${PLUGIN})
ADD_SUBDIRECTORY(${PLUGIN_DIR})
# Note: this will process the CMakeLists.txt file of the plugin resulting in
# PLUGIN_INCLUDE_DIRS being set, hence we can use it below to update
# our include directories
FOREACH(PLUGIN_INCLUDE_DIR ${PLUGIN_INCLUDE_DIRS})
INCLUDE_DIRECTORIES(${PLUGIN_DIR}/${PLUGIN_INCLUDE_DIR})
ENDFOREACH()
INCLUDE_DIRECTORIES(${PROJECT_BUILD_DIR}/${PLUGIN_DIR})
ENDFOREACH()
# Build the GUI version of OpenCOR
QT5_WRAP_CPP(SOURCES_MOC ${HEADERS_MOC})
QT5_WRAP_UI(SOURCES_UIS ${UIS})
QT5_ADD_RESOURCES(SOURCES_RCS ${RESOURCES})
IF(APPLE)
LIST(APPEND SOURCES
src/misc/macos.mm
)
ENDIF()
ADD_EXECUTABLE(${CMAKE_PROJECT_NAME} WIN32 MACOSX_BUNDLE
${SOURCES}
${SOURCES_MOC}
${SOURCES_UIS}
${SOURCES_RCS}
)
SET_TARGET_PROPERTIES(${CMAKE_PROJECT_NAME} PROPERTIES
OUTPUT_NAME ${CMAKE_PROJECT_NAME}
LINK_FLAGS "${LINK_FLAGS_PROPERTIES}"
)
IF(WIN32)
TARGET_LINK_LIBRARIES(${CMAKE_PROJECT_NAME}
${Qt5Core_QTMAIN_LIBRARIES}
)
ENDIF()
FOREACH(REQUIRED_QT_MODULE ${REQUIRED_QT_MODULES})
TARGET_LINK_LIBRARIES(${CMAKE_PROJECT_NAME}
Qt5::${REQUIRED_QT_MODULE}
)
ENDFOREACH()
# Build the CLI version of OpenCOR (Windows specific)
# Note: when it comes to WINDOWS_CLI_PROJECT_NAME, we used to have it set to
# ${CMAKE_PROJECT_NAME}.com, but Ninja found a duplicate rule (from a copy
# command), so now we use '_' instead of '.'...
IF(WIN32)
QT5_WRAP_CPP(WINDOWS_CLI_SOURCES_MOC ${WINDOWS_CLI_HEADERS_MOC})
QT5_ADD_RESOURCES(WINDOWS_CLI_SOURCES_RCS ${WINDOWS_CLI_RESOURCES})
SET(WINDOWS_CLI_PROJECT_NAME ${CMAKE_PROJECT_NAME}_com)
ADD_EXECUTABLE(${WINDOWS_CLI_PROJECT_NAME}
${WINDOWS_CLI_SOURCES}
${WINDOWS_CLI_SOURCES_MOC}
${WINDOWS_CLI_SOURCES_RCS}
)
TARGET_COMPILE_DEFINITIONS(${WINDOWS_CLI_PROJECT_NAME}
PRIVATE CLI_VERSION)
SET_TARGET_PROPERTIES(${WINDOWS_CLI_PROJECT_NAME} PROPERTIES
LINK_FLAGS "${LINK_FLAGS_PROPERTIES}"
)
TARGET_LINK_LIBRARIES(${WINDOWS_CLI_PROJECT_NAME}
Qt5::Core
Qt5::Network
)
ENDIF()
# Additional compiler and linker settings
ADD_DEFINITIONS(-D${CMAKE_PROJECT_NAME}_MAIN)
SET_TARGET_PROPERTIES(${CMAKE_PROJECT_NAME} PROPERTIES
LINK_FLAGS "${LINK_FLAGS_PROPERTIES}"
)
IF(WIN32)
SET_TARGET_PROPERTIES(${WINDOWS_CLI_PROJECT_NAME} PROPERTIES
LINK_FLAGS "${LINK_FLAGS_PROPERTIES}"
)
ENDIF()
# Some post-processing specific stuff
IF(APPLE)
# Configure and use our own Info.plist file
# Note: the reason for using our own Info.plist file is that it contains
# some information about associating .cellml files to OpenCOR,
# something that can't be done using CMake (or so it seems)...
SET(INFO_PLIST_FILENAME ${PROJECT_BUILD_DIR}/Info.plist)
CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/distrib/macos/Info.plist.in
${INFO_PLIST_FILENAME})
SET_TARGET_PROPERTIES(${CMAKE_PROJECT_NAME} PROPERTIES
MACOSX_BUNDLE_INFO_PLIST ${INFO_PLIST_FILENAME}
)
# Note: ideally, what follows would be done using macdeployqt, but it has
# regularly been causing us problems, so instead we have decided to do
# everything ourselves...
# Clean up the OpenCOR executable
MACOS_CLEAN_UP_FILE_WITH_QT_DEPENDENCIES(${CMAKE_PROJECT_NAME} ${PROJECT_BUILD_DIR}/${CMAKE_PROJECT_NAME}.app/Contents/MacOS ${CMAKE_PROJECT_NAME})
# Deploy our Qt libraries
# Note: the Qt Brew formula that we use on Travis CI misses QtDBus, which
# results in some of our tests generating messages about two
# frameworks being available and that one of them will be used, but
# that we don't know which one. So, to avoid those messages, we simply
# don't deploy the Qt frameworks...
IF(NOT ENABLE_TRAVIS_CI)
FOREACH(QT_LIBRARY ${MACOS_QT_LIBRARIES})
MACOS_DEPLOY_QT_LIBRARY(${QT_LIBRARY})
ENDFOREACH()
ENDIF()
# Deploy some plugins
MACOS_DEPLOY_QT_PLUGIN(imageformats qjpeg)
MACOS_DEPLOY_QT_PLUGIN(platforms qcocoa)
MACOS_DEPLOY_QT_PLUGIN(printsupport cocoaprintersupport)
MACOS_DEPLOY_QT_PLUGIN(sqldrivers qsqlite)
ELSE()
# Copy the GUI version of the OpenCOR executable to the build/bin folder
COPY_FILE_TO_BUILD_DIR(${CMAKE_PROJECT_NAME} ${PROJECT_BUILD_DIR} bin
${CMAKE_PROJECT_NAME}${CMAKE_EXECUTABLE_SUFFIX})
IF(WIN32)
# Copy the CLI version of the OpenCOR executable to both the build and
# build/bin folders
# Note: the idea is that, on Windows, we can test both the CLI and the
# GUI versions of OpenCOR from either build (the case when running
# OpenCOR from within Qt Creator) or build/bin (the case if we
# want to test OpenCOR as if it was deployed on someone's
# computer)...
SET(WINDOWS_CLI_COPY ${WINDOWS_CLI_PROJECT_NAME}_COPY)
ADD_CUSTOM_TARGET(${WINDOWS_CLI_COPY} ALL)
COPY_FILE_TO_BUILD_DIR(${WINDOWS_CLI_COPY} ${PROJECT_BUILD_DIR} .
${WINDOWS_CLI_PROJECT_NAME}${CMAKE_EXECUTABLE_SUFFIX} ${CMAKE_PROJECT_NAME}.com)
COPY_FILE_TO_BUILD_DIR(${WINDOWS_CLI_COPY} ${PROJECT_BUILD_DIR} bin
${WINDOWS_CLI_PROJECT_NAME}${CMAKE_EXECUTABLE_SUFFIX} ${CMAKE_PROJECT_NAME}.com)
ADD_DEPENDENCIES(${WINDOWS_CLI_COPY} ${WINDOWS_CLI_PROJECT_NAME})
# Additional files required by OpenCOR
# Note: these files may or not be needed in order to test OpenCOR
# locally. It all depends on the way the user's computer is set
# up. So, by copying them over, we are sure that the release/debug
# version of OpenCOR will work fine...
SET(MSVC_DIRNAME "C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/redist")
IF(NOT RELEASE_MODE)
SET(MSVC_DIRNAME "${MSVC_DIRNAME}/Debug_NonRedist")
ENDIF()
SET(MSVC_DIRNAME "${MSVC_DIRNAME}/x64")
IF(RELEASE_MODE)
SET(ADDITIONAL_FILES
${MSVC_DIRNAME}/Microsoft.VC140.CRT/msvcp140.dll
${MSVC_DIRNAME}/Microsoft.VC140.CRT/vcruntime140.dll
)
ELSE()
SET(ADDITIONAL_FILES
${MSVC_DIRNAME}/Microsoft.VC140.DebugCRT/msvcp140d.dll
${MSVC_DIRNAME}/Microsoft.VC140.DebugCRT/vcruntime140d.dll
)
ENDIF()
SET(WINDOWS_KIT_DIRNAME "C:/Program Files (x86)/Windows Kits/10/Redist/ucrt/DLLs/x64")
LIST(APPEND ADDITIONAL_FILES
${WINDOWS_KIT_DIRNAME}/api-ms-win-core-file-l1-2-0.dll
${WINDOWS_KIT_DIRNAME}/api-ms-win-core-file-l2-1-0.dll
${WINDOWS_KIT_DIRNAME}/api-ms-win-core-localization-l1-2-0.dll
${WINDOWS_KIT_DIRNAME}/api-ms-win-core-processthreads-l1-1-1.dll
${WINDOWS_KIT_DIRNAME}/api-ms-win-core-synch-l1-2-0.dll
${WINDOWS_KIT_DIRNAME}/api-ms-win-core-timezone-l1-1-0.dll
${WINDOWS_KIT_DIRNAME}/api-ms-win-crt-convert-l1-1-0.dll
${WINDOWS_KIT_DIRNAME}/api-ms-win-crt-environment-l1-1-0.dll
${WINDOWS_KIT_DIRNAME}/api-ms-win-crt-filesystem-l1-1-0.dll
${WINDOWS_KIT_DIRNAME}/api-ms-win-crt-heap-l1-1-0.dll
${WINDOWS_KIT_DIRNAME}/api-ms-win-crt-locale-l1-1-0.dll
${WINDOWS_KIT_DIRNAME}/api-ms-win-crt-math-l1-1-0.dll
${WINDOWS_KIT_DIRNAME}/api-ms-win-crt-multibyte-l1-1-0.dll
${WINDOWS_KIT_DIRNAME}/api-ms-win-crt-runtime-l1-1-0.dll
${WINDOWS_KIT_DIRNAME}/api-ms-win-crt-stdio-l1-1-0.dll
${WINDOWS_KIT_DIRNAME}/api-ms-win-crt-string-l1-1-0.dll
${WINDOWS_KIT_DIRNAME}/api-ms-win-crt-time-l1-1-0.dll
${WINDOWS_KIT_DIRNAME}/api-ms-win-crt-utility-l1-1-0.dll
${WINDOWS_KIT_DIRNAME}/ucrtbase.dll
)
FOREACH(ADDITIONAL_FILE ${ADDITIONAL_FILES})
GET_FILENAME_COMPONENT(DIRNAME ${ADDITIONAL_FILE} DIRECTORY)
GET_FILENAME_COMPONENT(FILENAME ${ADDITIONAL_FILE} NAME)
COPY_FILE_TO_BUILD_DIR(DIRECT ${DIRNAME} . ${FILENAME})
COPY_FILE_TO_BUILD_DIR(DIRECT ${DIRNAME} bin ${FILENAME})
ENDFOREACH()
# Finally, add Qt's version of the MESA 3D library so that we can run
# OpenCOR on machines that don't have 'proper' OpenGL support (e.g. on a
# Windows virtual machine in VirtualBox)
SET(ORIG_MESA3D_FILENAME opengl32sw.dll)
SET(DEST_MESA3D_FILENAME opengl32.dll)
COPY_FILE_TO_BUILD_DIR(DIRECT ${QT_BINARY_DIR} . ${ORIG_MESA3D_FILENAME} ${DEST_MESA3D_FILENAME})
COPY_FILE_TO_BUILD_DIR(DIRECT ${QT_BINARY_DIR} bin ${ORIG_MESA3D_FILENAME} ${DEST_MESA3D_FILENAME})
ELSE()
# Add our copy of the MESA 3D library so that we can run OpenCOR on
# machines that don't have 'proper' OpenGL support (e.g. on a Linux
# virtual machine in VirtualBox)
SET(MESA3D_FILENAME libGL.so.1)
RETRIEVE_BINARY_FILE(distrib/linux ${MESA3D_FILENAME} 0b2eb56efe43507026af87f036f96ec4e5b2c707)
COPY_FILE_TO_BUILD_DIR(DIRECT ${CMAKE_SOURCE_DIR}/distrib/bin lib ${MESA3D_FILENAME})
ENDIF()
ENDIF()
# Package OpenCOR
SET(CPACK_PACKAGE_NAME "${CMAKE_PROJECT_NAME}")
SET(CPACK_PACKAGE_CONTACT "Team OpenCOR (team@opencor.ws)")
SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "${PROJECT_DESCRIPTION}")
SET(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_SOURCE_DIR}/distrib/readMe.txt")
SET(CPACK_PACKAGE_INSTALL_DIRECTORY "${CMAKE_PROJECT_NAME}")
SET(CPACK_PACKAGE_EXECUTABLES "${CMAKE_PROJECT_NAME}" "${CMAKE_PROJECT_NAME}")
SET(CPACK_PACKAGE_VENDOR "Physiome Project")
SET(CPACK_PACKAGE_VERSION "${VERSION}")
IF(SNAPSHOT)
SET(CPACK_PACKAGE_VERSION_PATCH "")
ELSE()
SET(CPACK_PACKAGE_VERSION_PATCH "${PROJECT_VERSION_PATCH}")
ENDIF()
IF(WIN32)
# Select NSIS, if available, and ZIP as the packagers on Windows
IF( EXISTS "C:/Program\ Files/NSIS/makensis.exe"
OR EXISTS "C:/Program\ Files\ (x86)/NSIS/makensis.exe")
SET(NSIS_FOUND TRUE)
SET(NSIS_GENERATOR NSIS)
ELSE()
SET(NSIS_FOUND FALSE)
SET(NSIS_GENERATOR)
ENDIF()
SET(CPACK_GENERATOR ${NSIS_GENERATOR} ZIP)
SET(CPACK_SYSTEM_NAME "Windows")
SET(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/LICENSE.txt")
# Specify the default installation directory
IF(NSIS_FOUND)
SET(CPACK_NSIS_INSTALL_ROOT "$PROGRAMFILES64")
SET(CPACK_NSIS_INSTALLED_ICON_NAME "bin\\\\${CMAKE_PROJECT_NAME}.exe")
ENDIF()
# Install both the GUI and CLI versions of OpenCOR
INSTALL(TARGETS ${CMAKE_PROJECT_NAME} RUNTIME DESTINATION bin)
INSTALL(FILES ${PROJECT_BUILD_DIR}/bin/${CMAKE_PROJECT_NAME}.com
DESTINATION bin)
# Additional files required by OpenCOR (incl. the Mesa 3D Library)
INSTALL(FILES ${ADDITIONAL_FILES}
DESTINATION bin)
INSTALL(FILES ${QT_BINARY_DIR}/${ORIG_MESA3D_FILENAME}
DESTINATION bin
RENAME ${DEST_MESA3D_FILENAME})
# Qt libraries required by OpenCOR
IF(ENABLE_TESTS)
SET(TEST Test)
ELSE()
SET(TEST)
ENDIF()
FOREACH(QT_LIBRARY CLucene Core Gui Help Multimedia MultimediaWidgets Network OpenGL Positioning PrintSupport Qml Quick Sensors Sql Svg ${TEST} WebChannel WebKit WebKitWidgets Widgets Xml XmlPatterns)
WINDOWS_DEPLOY_QT_LIBRARY(Qt5${QT_LIBRARY})
ENDFOREACH()
FOREACH(QT_LIBRARY icudt icuin icuuc)
WINDOWS_DEPLOY_QT_LIBRARY(${QT_LIBRARY}57)
ENDFOREACH()
# Qt plugins required by OpenCOR
WINDOWS_DEPLOY_QT_PLUGIN(imageformats qjpeg)
WINDOWS_DEPLOY_QT_PLUGIN(platforms qwindows)
WINDOWS_DEPLOY_QT_PLUGIN(printsupport windowsprintersupport)
WINDOWS_DEPLOY_QT_PLUGIN(sqldrivers qsqlite)
# Batch and VBScript files to run OpenCOR (useful when downloading a ZIPped
# version of OpenCOR)
SET(BAT_FILENAME "${PROJECT_BUILD_DIR}/${CMAKE_PROJECT_NAME}.bat")
SET(VBS_FILENAME "${PROJECT_BUILD_DIR}/${CMAKE_PROJECT_NAME}.vbs")
CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/distrib/windows/application.bat.in
${BAT_FILENAME})
CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/distrib/windows/application.vbs.in
${VBS_FILENAME})
INSTALL(FILES ${BAT_FILENAME}
DESTINATION .)
INSTALL(FILES ${VBS_FILENAME}
DESTINATION .)
# File type association
# Note: the calls to SHChangeNotify are to ensure that Windows refreshes
# file icons (so that it is clear to the user that an extension has
# been (un)registered...
IF(NSIS_FOUND)
SET(CPACK_NSIS_DEFINES "!include ${CMAKE_SOURCE_DIR}\\\\distrib\\\\windows\\\\FileAssociation.nsh")
SET(CPACK_NSIS_EXTRA_INSTALL_COMMANDS "
\\\${RegisterExtension} \\\"\\\$INSTDIR\\\\bin\\\\${CMAKE_PROJECT_NAME}${CMAKE_EXECUTABLE_SUFFIX}\\\" \\\".cellml\\\" \\\"CellML File\\\"
System::Call \\\"Shell32::SHChangeNotify(i 0x08000000, i 0, i 0, i 0)\\\"
")
SET(CPACK_NSIS_EXTRA_UNINSTALL_COMMANDS "
\\\${UnregisterExtension} \\\".cellml\\\" \\\"CellML File\\\"
System::Call \\\"Shell32::SHChangeNotify(i 0x08000000, i 0, i 0, i 0)\\\"
")
ENDIF()
ELSEIF(APPLE)
# Select PackageMaker and ZIP as the packagers on macOS
# Note: this is actually done within the package script, so that the ZIP
# package can be done 'properly', i.e. we don't have the full tree
# structure in the ZIP file...
SET(CPACK_SYSTEM_NAME "macOS")
SET(CPACK_RESOURCE_FILE_WELCOME "${CMAKE_SOURCE_DIR}/distrib/macos/welcome.txt")
SET(CPACK_RESOURCE_FILE_README "${CMAKE_SOURCE_DIR}/distrib/readMe.txt")
SET(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/LICENSE.txt")
SET(CPACK_SET_DESTDIR TRUE)
INSTALL(TARGETS ${CMAKE_PROJECT_NAME} BUNDLE
DESTINATION .)
# Shell script to run OpenCOR (useful when downloading a ZIPped version of
# OpenCOR)
SET(SH_FILENAME ${PROJECT_BUILD_DIR}/${CMAKE_PROJECT_NAME}.sh)
CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/distrib/macos/application.sh.in
${SH_FILENAME})
INSTALL(FILES ${SH_FILENAME}
DESTINATION .
RENAME ${CMAKE_PROJECT_NAME}
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
ELSE()
# Select TGZ as the packager on Linux
SET(CPACK_GENERATOR TGZ)
SET(CPACK_SYSTEM_NAME "Linux")
# OpenCOR itself
INSTALL(TARGETS ${CMAKE_PROJECT_NAME} RUNTIME DESTINATION bin)
# Libraries needed on (at least) Ubuntu 16.04 LTS, but not on Ubuntu 14.04
# LTS
FOREACH(LIBRARY app base interfaces pbutils reamer video)
SET(FULL_LIBRARY ${CMAKE_SHARED_LIBRARY_PREFIX}gst${LIBRARY}-0.10${CMAKE_SHARED_LIBRARY_SUFFIX}.0)
GET_FILENAME_COMPONENT(REAL_FULL_LIBRARY /usr/lib/x86_64-linux-gnu/${FULL_LIBRARY} REALPATH)
INSTALL(FILES ${REAL_FULL_LIBRARY}
DESTINATION lib
RENAME ${FULL_LIBRARY})
ENDFOREACH()
# Library needed on Ubuntu 14.04 LTS, but not on Ubuntu 16.06 LTS
# Note: this is due to our use of GCC/G++ 4.9+, which is not originally
# present on Ubuntu 14.04 LTS...
INSTALL(FILES /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.22
DESTINATION lib
RENAME libstdc++.so.6)
# Library needed on Fedora, but not on Ubuntu
FOREACH(LIBRARY bz2.so.1.0)
SET(FULL_LIBRARY ${CMAKE_SHARED_LIBRARY_PREFIX}${LIBRARY})
GET_FILENAME_COMPONENT(REAL_FULL_LIBRARY /lib/x86_64-linux-gnu/${FULL_LIBRARY} REALPATH)
INSTALL(FILES ${REAL_FULL_LIBRARY}
DESTINATION lib
RENAME ${FULL_LIBRARY})
ENDFOREACH()
# Mesa 3D graphics library
INSTALL(FILES ${CMAKE_SOURCE_DIR}/distrib/bin/${MESA3D_FILENAME}
DESTINATION lib)
# Qt libraries required by OpenCOR
# Note: unlike for Windows and macOS, we don't have a macro for deploying
# all of our Qt libraries at once. Indeed, on Linux, the version of a
# file is appended to its suffix, so unless making the macro
# unnecessarily cumbersome to use, it's better to deploy one Qt
# library at a time...
IF(ENABLE_TESTS)
SET(TEST Test)
ELSE()
SET(TEST)
ENDIF()
FOREACH(QT_LIBRARY CLucene Core DBus Gui Help Multimedia MultimediaWidgets Network OpenGL Positioning PrintSupport Qml Quick Sensors Sql Svg ${TEST} WebChannel WebKit WebKitWidgets Widgets XcbQpa Xml XmlPatterns)
IF( "${QT_LIBRARY}" STREQUAL "WebKit"
OR "${QT_LIBRARY}" STREQUAL "WebKitWidgets")
SET(REAL_QT_LIBRARY_DIR ${QT_WEBKIT_LIBRARIES_DIR})
ELSE()
SET(REAL_QT_LIBRARY_DIR ${QT_LIBRARY_DIR})
ENDIF()
LINUX_DEPLOY_QT_LIBRARY(${REAL_QT_LIBRARY_DIR} ${CMAKE_SHARED_LIBRARY_PREFIX}Qt${QT_VERSION_MAJOR}${QT_LIBRARY}${CMAKE_SHARED_LIBRARY_SUFFIX}.${QT_VERSION_MAJOR})
ENDFOREACH()
IF(NOT ENABLE_TRAVIS_CI)
# We are building OpenCOR locally, so we can deploy the ICU libraries
# Note: indeed, on Travis CI, the PPA we use doesn't have those
# libraries...
FOREACH(QT_FILE icudata icui18n icuuc)
LINUX_DEPLOY_QT_LIBRARY(${QT_LIBRARY_DIR} ${CMAKE_SHARED_LIBRARY_PREFIX}${QT_FILE}${CMAKE_SHARED_LIBRARY_SUFFIX}.56)
ENDFOREACH()
ENDIF()
# Qt plugins required by OpenCOR
LINUX_DEPLOY_QT_PLUGIN(imageformats qjpeg)
LINUX_DEPLOY_QT_PLUGIN(platforms qxcb)
LINUX_DEPLOY_QT_PLUGIN(printsupport cupsprintersupport)
LINUX_DEPLOY_QT_PLUGIN(sqldrivers qsqlite)
IF(NOT ENABLE_TRAVIS_CI)
# We are building OpenCOR locally, so we can deploy the
# xcbglintegrations plugins
# Note: indeed, on Travis CI, the PPA we use doesn't have those
# plugins...
LINUX_DEPLOY_QT_PLUGIN(xcbglintegrations qxcb-egl-integration qxcb-glx-integration)
ENDIF()
# Shell script to run OpenCOR
SET(SH_FILENAME ${PROJECT_BUILD_DIR}/${CMAKE_PROJECT_NAME}.sh)
CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/distrib/linux/application.sh.in
${SH_FILENAME})
INSTALL(FILES ${SH_FILENAME}
DESTINATION .
RENAME ${CMAKE_PROJECT_NAME}
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
ENDIF()
# Specify the package file name, depending on whether we are generating a
# snapshot version of OpenCOR
IF(SNAPSHOT)
SET(CPACK_PACKAGE_FILE_NAME ${CPACK_PACKAGE_NAME}-${DATE}-${CPACK_SYSTEM_NAME})
ELSE()
SET(CPACK_PACKAGE_FILE_NAME ${CPACK_PACKAGE_NAME}-${PROJECT_VERSION_MAJOR}-${PROJECT_VERSION_MINOR})
IF(NOT "${PROJECT_VERSION_PATCH}" STREQUAL "")
SET(CPACK_PACKAGE_FILE_NAME ${CPACK_PACKAGE_FILE_NAME}-${PROJECT_VERSION_PATCH})
ENDIF()
SET(CPACK_PACKAGE_FILE_NAME ${CPACK_PACKAGE_FILE_NAME}-${CPACK_SYSTEM_NAME})
ENDIF()
# Notice and license files
SET(NOTICE_FILENAME ${PROJECT_BUILD_DIR}/NOTICE.txt)
CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/NOTICE.txt.in
${NOTICE_FILENAME})
SET(FILES
${CMAKE_SOURCE_DIR}/LICENSE.txt
${NOTICE_FILENAME}
)
FOREACH(FILE ${FILES})
INSTALL(FILES ${FILE}
DESTINATION .
PERMISSIONS OWNER_READ GROUP_READ WORLD_READ)
ENDFOREACH()
# Some sample CellML files
SET(MODEL_FILES
hodgkin_huxley_squid_axon_model_1952.cellml
noble_model_1962.cellml
van_der_pol_model_1928.cellml
)
FOREACH(MODEL_FILE ${MODEL_FILES})
INSTALL(FILES ${CMAKE_SOURCE_DIR}/models/${MODEL_FILE}
DESTINATION models
PERMISSIONS OWNER_READ GROUP_READ WORLD_READ)
ENDFOREACH()
# Some user-defined format files
SET(FORMAT_FILES
C.xml
F77.xml
MATLAB.xml
Python.xml
README.txt
)
FOREACH(FORMAT_FILE ${FORMAT_FILES})
INSTALL(FILES ${CMAKE_SOURCE_DIR}/formats/${FORMAT_FILE}
DESTINATION formats
PERMISSIONS OWNER_READ GROUP_READ WORLD_READ)
ENDFOREACH()
INCLUDE(CPack)