-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
439 lines (347 loc) · 14.8 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
cmake_minimum_required(VERSION 3.21.0)
project(SupraFit
VERSION 2.6.0
LANGUAGES CXX)
# set the module path
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/modules)
# As moc files are generated in the binary dir, tell CMake
# to always look for includes there:
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# Tell CMake to run moc when necessary:
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
option (BENCHMARK_LEVEL
"Benchmark output enabled" OFF)
option (experimental
"Include experimental functions" OFF)
option (testing
"Enable unittests" OFF)
option (NMR_Models
"Enable NMR Titration models" ON)
option (ITC_Models
"Enable ITC Titration models" ON)
option (Kinetic_Models
"Enable Kinetic Models" ON)
option (Fluorescence_Models
"Enable Fluorescence Models" ON)
option (extended_f_test
"Extend f-test methods for sigma, chi and SEy" OFF)
option (legacy
"Enable Legacy Concentration Handling - For benchmark purpose (only)" OFF)
option (conservative
"Enable conservative calculations, slower and not better" OFF)
option (noto_font
"Enable and Use Google Noto Fonts" OFF)
option (_Theme
"Use Icon Theme from Desktop Environment, It does not work on Windows" OFF)
option (_Python
"Enable python interface" OFF)
option (_Models
"Enable custom models" ON)
option (Use_Duktape
"Use Duktape script engine" OFF )
# Get the current working branch
execute_process(
COMMAND git rev-parse --abbrev-ref HEAD
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE GIT_BRANCH
OUTPUT_STRIP_TRAILING_WHITESPACE
)
# Get the latest tag within the working branch
execute_process(
COMMAND git describe --tags
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE GIT_COMMIT_TAG
OUTPUT_STRIP_TRAILING_WHITESPACE
)
execute_process(
COMMAND git log -1 --format=%h
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE GIT_COMMIT_HASH
OUTPUT_STRIP_TRAILING_WHITESPACE
)
if(UNIX) # dont work on windows systems, compilation fails unfortranatly ...
execute_process(
COMMAND git log -1 --format=%aD
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE GIT_COMMIT_DATE
OUTPUT_STRIP_TRAILING_WHITESPACE
)
endif(UNIX)
add_definitions("-DGIT_COMMIT_HASH=${GIT_COMMIT_HASH}")
add_definitions("-DGIT_BRANCH=${GIT_BRANCH}")
add_definitions("-DGIT_COMMIT_DATE=${GIT_COMMIT_DATE}")
add_definitions("-DGIT_COMMIT_TAG=${GIT_COMMIT_TAG}")
if (CMAKE_BUILD_TYPE STREQUAL "DEBUG")
set (_DEBUG ON)
endif(CMAKE_BUILD_TYPE STREQUAL "DEBUG")
if(WIN32) # Check if we are on Windows
set (_Theme OFF)
endif(WIN32)
if(CMAKE_COMPILER_IS_GNUCXX)
set (_UNIX ON)
find_package(OpenMP)
if (OPENMP_FOUND)
if(NOT WIN32)
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
set (openMP ON)
endif(NOT WIN32)
endif()
endif()
IF(CMAKE_COMPILER_IS_GNUCXX)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wno-reorder -pedantic \
-Wextra -Wcast-align -Wcast-qual -Wchar-subscripts \
-Wcomment -Wdisabled-optimization \
-Wformat -Wformat=2 -Wformat-nonliteral -Wformat-security\
-Wformat-y2k -Wimport -Winit-self -Winline -Winvalid-pch\
-Wunsafe-loop-optimizations -Wmissing-braces\
-Wmissing-field-initializers -Wmissing-format-attribute \
-Wmissing-include-dirs -Wmissing-noreturn -Wpacked -Wparentheses\
-Wpointer-arith -Wredundant-decls -Wsequence-point\
-Wsign-compare -Wstack-protector -Wstrict-aliasing\
-Wstrict-aliasing=2 -Wswitch -Wsuggest-override\
-Wtrigraphs -Wuninitialized -Wunknown-pragmas -Wunreachable-code\
-Wunused -Wunused-function -Wunused-label -Wunused-parameter\
-Wunused-value -Wunused-variable -Wvariadic-macros\
-Wvolatile-register-var -Wwrite-strings -Wdeprecated-declarations\
-Wno-error=unused-local-typedefs -Wno-error=enum-compare -Wno-narrowing -Werror=return-type")
ENDIF(CMAKE_COMPILER_IS_GNUCXX)
find_package(Qt6 6.5 COMPONENTS Core Widgets Charts Qml)
if(_Python)
find_package(PythonLibs)
if( NOT PythonLibs_FOUND)
message(FATAL_ERROR "Python is not found on your system. Please rerun cmake with disabled Python support!")
endif()
endif()
add_subdirectory(${PROJECT_SOURCE_DIR}/external/fmt EXCLUDE_FROM_ALL)
include_directories(SYSTEM ${QT_INCLUDES} ${PROJECT_SOURCE_DIR}/external/fmt/include ${PROJECT_SOURCE_DIR}/external/libpeakpick/eigen/ ${PYTHON_INCLUDE_DIRS} ${PROJECT_SOURCE_DIR}/external/ChaiScript/include/ ${PROJECT_SOURCE_DIR}/external/ChaiScript_Extras/include/)
include_directories(${CMAKE_CURRENT_BINARY_DIR} ${PROJECT_SOURCE_DIR} ${PROJECT_SOURCE_DIR}/external/fisher_dist/ ${PROJECT_SOURCE_DIR}/external/libpeakpick/ ${PROJECT_SOURCE_DIR}/external/CuteChart/src/ ${PROJECT_SOURCE_DIR}/external/CxxThreadPool/include ${PROJECT_SOURCE_DIR}/external/EqnConc/include)
#${PROJECT_SOURCE_DIR}/external/CxxClust/ )
configure_file (
"${PROJECT_SOURCE_DIR}/src/global_config.h.in"
"${PROJECT_BINARY_DIR}/src/global_config.h"
)
configure_file(
"${CMAKE_SOURCE_DIR}/src/version.h.in"
"${CMAKE_BINARY_DIR}/src/version.h"
)
if(Use_Duktape)
include_directories(SYSTEM ${PROJECT_SOURCE_DIR}/external/duktape/src)
endif()
# include the charts, which where formerly part of SupraFit
add_subdirectory(external/CuteChart)
set(core_SRC
src/core/equil.cpp
src/core/libmath.cpp
src/core/minimizer.cpp
src/core/optimizer/eigen_levenberg.cpp
src/capabilities/datagenerator.cpp
src/capabilities/resampleanalyse.cpp
src/capabilities/abstractsearchclass.cpp
src/capabilities/modelcomparison.cpp
src/capabilities/montecarlostatistics.cpp
src/capabilities/globalsearch.cpp
src/capabilities/weakenedgridsearch.cpp
src/capabilities/jobmanager.cpp
src/core/analyse.cpp
src/core/jsonhandler.cpp
src/core/filehandler.cpp
src/core/toolset.cpp
src/core/thermogramhandler.cpp
src/core/spectrahandler.cpp
src/core/concentrationalpolynomial.cpp
src/global.cpp
)
IF(_Python)
set(python_SRC
src/core/pythonbridge.cpp
)
ENDIF(_Python)
if(_Python)
add_library(core SHARED ${core_SRC})
else()
add_library(core ${core_SRC})
endif()
target_link_libraries(core Qt::Core Qt::Qml)
#add_subdirectory(src/core/models/misc)
set(models_SRC
src/core/models/dataclass.cpp
src/core/models/datatable.cpp
src/core/models/AbstractModel.cpp
src/core/models/titrations/AbstractItcModel.cpp
src/core/models/titrations/AbstractTitrationModel.cpp
src/core/models/titrations/AbstractNMRModel.cpp
src/core/models/meta_model.cpp
src/core/models/scriptmodel.cpp
src/core/models/pymodelinterpreter.cpp
src/core/models/chaiinterpreter.cpp
src/core/models/kinetics/mm_model.cpp
src/core/models/kinetics/monomolecularmodel.cpp
src/core/models/kinetics/bimolecularmodel.cpp
src/core/models/kinetics/flexmolecularmodel.cpp
src/core/models/kinetics/tian.cpp
src/core/models/kinetics/evap.cpp
src/core/models/postprocess/statistic.cpp
src/core/models/postprocess/thermo.cpp
src/core/models/misc/indep_quadrat.cpp
src/core/models/misc/dep_any.cpp
src/core/models/photophysics/decayrates.cpp
src/core/models/thermodynamics/eyring.cpp
src/core/models/thermodynamics/arrhenius.cpp
src/core/models/thermodynamics/bet.cpp
src/core/models/titrations/fluorescence/fl_1_1_1_2_Model.cpp
src/core/models/titrations/fluorescence/fl_1_1_Model.cpp
src/core/models/titrations/fluorescence/fl_2_1_1_1_1_2_Model.cpp
src/core/models/titrations/fluorescence/fl_2_1_1_1_Model.cpp
src/core/models/titrations/itc/blank.cpp
src/core/models/titrations/itc/itc_1_1_Model.cpp
src/core/models/titrations/itc/itc_1_2_Model.cpp
src/core/models/titrations/itc/itc_2_1_Model.cpp
src/core/models/titrations/itc/itc_2_2_Model.cpp
src/core/models/titrations/itc/itc_n_1_1_Model.cpp
src/core/models/titrations/itc/itc_n_1_2_Model.cpp
src/core/models/titrations/itc/itc_any_Model.cpp
src/core/models/titrations/nmr/nmr_1_1_1_2_Model.cpp
src/core/models/titrations/nmr/nmr_1_1_Model.cpp
src/core/models/titrations/nmr/nmr_2_1_1_1_1_2_Model.cpp
src/core/models/titrations/nmr/nmr_2_1_1_1_Model.cpp
src/core/models/titrations/nmr/nmr_any_Model.cpp
src/core/models/titrations/uv_vis/uv_vis_1_1_1_2_Model.cpp
src/core/models/titrations/uv_vis/uv_vis_1_1_Model.cpp
src/core/models/titrations/uv_vis/uv_vis_2_1_1_1_1_2_Model.cpp
src/core/models/titrations/uv_vis/uv_vis_2_1_1_1_Model.cpp
src/core/models/titrations/uv_vis/uvvis_any_Model.cpp
)
IF(Use_Duktape)
set(duke_SRC
external/duktape/src/duktape.c
src/core/models/dukmodelinterpreter.cpp
)
set_source_files_properties(external/duktape/src/duktape.c PROPERTIES LANGUAGE CXX)
add_library(duke SHARED ${duke_SRC})
ENDIF()
if(_Python)
add_library(models SHARED ${models_SRC})
else()
add_library(models ${models_SRC})
endif()
target_link_libraries(models Qt::Core ${PYTHON_LIBRARIES} Qt::Qml)
IF(Use_Duktape)
target_link_libraries(models duke)
ENDIF()
add_subdirectory(src/ui)
set(suprafit_SRC
src/ui/instance.h
src/ui/main.cpp
)
qt_add_resources(suprafit_SRC files.qrc)
if(noto_font)
qt_add_resources(suprafit_SRC fonts.qrc)
endif(noto_font)
# generate proper GUI program on specified platform
if(WIN32) # Check if we are on Windows
add_executable(suprafit ${suprafit_SRC} suprafit.rc)
if(MSVC) # Check if we are using the Visual Studio compiler
set_target_properties(suprafit PROPERTIES
WIN32_EXECUTABLE YES
LINK_FLAGS "/ENTRY:mainCRTStartup"
)
#set_property(TARGET suprafit PROPERTY
#MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
elseif(CMAKE_COMPILER_IS_GNUCXX)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mwindows") # Not tested but seems to work
else()
message(SEND_ERROR "You are using an unsupported Windows compiler! (Not MSVC or GCC)")
endif(MSVC)
set(target_dir "bin/win")
set_target_properties(suprafit PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${target_dir} )
elseif(APPLE)
set(SupraFit_icon ${CMAKE_CURRENT_SOURCE_DIR}/misc/SupraFit.icns)
set_source_files_properties(${SupraFit_icon} PROPERTIES
MACOSX_PACKAGE_LOCATION "Resources")
set(MACOSX_BUNDLE_ICON_FILE "SupraFit.icns")
set(target_dir "bin/macOS")
add_executable(suprafit MACOSX_BUNDLE ${SupraFit_icon} ${suprafit_SRC})
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
set(target_dir "bin/linux")
add_executable(suprafit ${suprafit_SRC})
set_target_properties(suprafit PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${target_dir} )
else()
message(SEND_ERROR "You are on an unsupported platform! (Not Win, Mac OS X or Unix)")
endif(WIN32)
set_target_properties(suprafit PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${target_dir} )
set(suprafit_cli_SRCS
src/client/suprafit_cli.cpp
src/client/analyser.cpp
src/client/simulator.cpp
src/client/main.cpp
)
add_executable(suprafit_cli ${suprafit_cli_SRCS})
set_target_properties(suprafit_cli PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${target_dir} )
IF(_Python)
set(python_cli_SRCS
src/python/main.cpp
)
add_executable(python_cli ${python_cli_SRCS})
set_target_properties(python_cli PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${target_dir} )
add_library(pythonbridge SHARED ${python_SRC})
set_property(TARGET pythonbridge PROPERTY CXX_STANDARD 17)
set_target_properties(pythonbridge PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${target_dir} )
target_link_libraries(pythonbridge models core)
target_link_libraries(python_cli pythonbridge)
set_property(TARGET python_cli PROPERTY CXX_STANDARD 17)
ENDIF()
set_property(TARGET core models PROPERTY CXX_STANDARD 17)
set_property(TARGET suprafit PROPERTY CXX_STANDARD 17)
set_property(TARGET suprafit_cli PROPERTY CXX_STANDARD 17)
set_target_properties(core PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${target_dir} )
set_target_properties(models PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${target_dir} )
target_link_libraries(suprafit suprafit_gui models core cutechart fmt::fmt-header-only)
set(CMAKE_EXE_LINKER_FLAGS "-static-libgcc -static-libstdc++")
target_link_libraries(suprafit_cli models core fmt::fmt-header-only)
if(testing)
enable_testing()
set(basic_test
test/save_and_load.cpp
)
add_test( basic_test supratest )
add_executable(supratest ${basic_test})
#set_property(TARGET suprafit PROPERTY ENABLE_EXPORTS true)
set_property(TARGET supratest PROPERTY CXX_STANDARD 17)
target_link_libraries(supratest Qt::Core Qt::Test)
target_link_libraries(supratest utils models math suprafit ${QT_QTCORE_LIBRARY})
endif(testing)
if(UNIX)
target_link_libraries(suprafit pthread dl)
target_link_libraries(suprafit_cli pthread dl)
endif(UNIX)
# Do platform specific post target stuff
if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
install(TARGETS suprafit RUNTIME DESTINATION bin)
install(TARGETS suprafit_cli RUNTIME DESTINATION bin)
install(TARGETS models LIBRARY DESTINATION lib)
install(TARGETS core LIBRARY DESTINATION lib)
if(_Python)
install(TARGETS pythonbridge LIBRARY DESTINATION lib)
ENDIF(_Python)
#install(FILES src/python/main.py DESTINATION lib)
# Install desktop entry
install(FILES misc/SupraFit.desktop DESTINATION share/applications )
# Install icon
install(FILES misc/SupraFit.png DESTINATION share/icons/pixmaps/)
elseif(APPLE)
#string(REPLACE "qmake" "" qt_dir ${QT_QMAKE_EXECUTABLE})
# add_custom_command(TARGET suprafit POST_BUILD
# COMMAND ${QT_INSTALL_BINS}/macdeployqt suprafit.app -dmg -no-plugins
# WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/${target_dir}
# )
elseif(WIN32)
#string(REPLACE "qmake" "" qt_dir ${QT_QMAKE_EXECUTABLE})
#add_custom_command(TARGET suprafit POST_BUILD
# COMMAND ${qt_dir}/windeployqt --release suprafit.app
# WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/${target_dir}
# )
endif (${CMAKE_SYSTEM_NAME} MATCHES "Linux")