forked from DyssolTEC/Dyssol-open
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
265 lines (212 loc) · 9.13 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
# Copyright (c) 2020, Dyssol Development Team. All rights reserved. This file is part of Dyssol. See LICENSE file for license information.
# Copyright (c) 2021, Anton Gladky <[email protected]>, IART, Technical University Bergakademie Freiberg
cmake_minimum_required(VERSION 3.1.0)
set (VERSION 1.1.1)
set (SOVERSION 1.0)
OPTION(BUILD_BINARIES "Whether to build binary files" ON)
OPTION(BUILD_DOCS "Whether to build documentation" ON)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
project(Dyssol VERSION ${VERSION} LANGUAGES CXX)
INCLUDE(GNUInstallDirs)
SET(CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR})
SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
SET(INSTALL_UNITS_LIB_PATH ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/Dyssol/Units)
SET(INSTALL_MATERIALDB_PATH ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_DATADIR}/Dyssol/MaterialsDB)
SET(INSTALL_DOCS_PATH ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_DATADIR}/Dyssol/docs)
SET(INSTALL_CONFIG_PATH ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_DATADIR}/Dyssol/)
SET(INSTALL_HEADERS_PATH ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR}/)
SET(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
##################################################
### Binaries
IF(BUILD_BINARIES)
add_executable(DyssolC
${CMAKE_SOURCE_DIR}/DyssolConsole/main.cpp
)
set(libdyssolnames
"BaseSolvers"
"CacheHandler"
"EquationSolvers"
"HDF5Handler"
"MaterialsDatabase"
"ModelsAPI"
"Modules"
"ScriptInterface"
"SimulatorCore"
"Utilities"
"Modules/DustFormationTester"
)
foreach(foldername ${libdyssolnames})
file(GLOB_RECURSE src ${CMAKE_SOURCE_DIR}/${foldername}/*.cpp)
file(GLOB_RECURSE hdr ${CMAKE_SOURCE_DIR}/${foldername}/*.h)
set(libdyssolsrc ${libdyssolsrc} ${src})
INCLUDE_DIRECTORIES("${CMAKE_SOURCE_DIR}/${foldername}/")
INSTALL(FILES ${hdr} DESTINATION ${INSTALL_HEADERS_PATH}/Dyssol/${foldername}/)
endforeach(foldername ${libdyssolnames})
FIND_PACKAGE(HDF5 REQUIRED COMPONENTS "CXX" "HL")
INCLUDE_DIRECTORIES(${HDF5_INCLUDE_DIRS})
FIND_PACKAGE(SUNDIALS REQUIRED COMPONENTS sundials_ida sundials_kinsol sundials_nvecserial)
INCLUDE_DIRECTORIES(${SUNDIALS_INCLUDE_DIRS})
ADD_LIBRARY(libdyssol_shared SHARED ${libdyssolsrc})
SET_TARGET_PROPERTIES(libdyssol_shared PROPERTIES
VERSION ${VERSION}
SOVERSION ${SOVERSION}
PREFIX ""
OUTPUT_NAME "libdyssol"
)
ADD_LIBRARY(libdyssol_static STATIC ${libdyssolsrc})
SET_TARGET_PROPERTIES(libdyssol_static PROPERTIES
VERSION ${VERSION}
SOVERSION ${SOVERSION}
PREFIX ""
OUTPUT_NAME "libdyssol"
)
target_compile_definitions(libdyssol_shared PRIVATE INSTALL_DOCS_PATH="${INSTALL_DOCS_PATH}")
target_compile_definitions(libdyssol_static PRIVATE INSTALL_DOCS_PATH="${INSTALL_DOCS_PATH}")
TARGET_LINK_LIBRARIES(libdyssol_shared ${HDF5_LIBRARIES} ${HDF5_HL_LIBRARIES} ${SUNDIALS_LIBRARIES})
TARGET_LINK_LIBRARIES(libdyssol_static ${HDF5_LIBRARIES} ${HDF5_HL_LIBRARIES} ${SUNDIALS_LIBRARIES})
TARGET_LINK_LIBRARIES(DyssolC libdyssol_shared)
FIND_PACKAGE(Graphviz)
IF(Graphviz_FOUND)
MESSAGE(STATUS "Graphviz is found")
MESSAGE(STATUS ${Graphviz_INCLUDE_DIR})
ADD_DEFINITIONS("-DGRAPHVIZ")
TARGET_LINK_LIBRARIES(libdyssol_shared ${Graphviz_LIBRARIES})
TARGET_LINK_LIBRARIES(libdyssol_static ${Graphviz_LIBRARIES})
INCLUDE_DIRECTORIES(${Graphviz_INCLUDE_DIR})
ENDIF(Graphviz_FOUND)
CONFIGURE_FILE("${CMAKE_SOURCE_DIR}/DyssolMainWindow/config.ini.in" "${CMAKE_BINARY_DIR}/config.ini")
INSTALL(FILES "${CMAKE_BINARY_DIR}/config.ini" DESTINATION ${INSTALL_CONFIG_PATH})
INSTALL(FILES "${CMAKE_SOURCE_DIR}/Materials.dmdb" DESTINATION ${INSTALL_MATERIALDB_PATH})
INSTALL(TARGETS DyssolC DESTINATION ${CMAKE_INSTALL_BINDIR})
INSTALL(TARGETS libdyssol_shared DESTINATION ${CMAKE_INSTALL_LIBDIR})
INSTALL(TARGETS libdyssol_static DESTINATION ${CMAKE_INSTALL_LIBDIR})
ADD_SUBDIRECTORY("${CMAKE_SOURCE_DIR}/Units")
ADD_SUBDIRECTORY("${CMAKE_SOURCE_DIR}/Solvers")
ADD_SUBDIRECTORY("${CMAKE_SOURCE_DIR}/DyssolMainWindow")
SET(INSTALL_DOCS_PATH ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_DATADIR}/Dyssol/docs)
##################################################
### Testing
ENABLE_TESTING()
SET(TESTS
"Unit_Agglomerator_CellAverage"
"Unit_Agglomerator_FFT"
"Unit_Agglomerator_FixedPivot"
"Unit_Bunker_Adaptive"
"Unit_Bunker_Constant"
"Unit_Crusher_BondBimodal"
"Unit_Crusher_BondNormal"
"Unit_Crusher_Cone"
"Unit_Crusher_Const"
"Unit_Crusher_PBMTM"
"Unit_Cyclone_Muschelknautz"
"Unit_Granulator"
"Unit_GranulatorSimpleBatch"
"Unit_Mixer"
"Unit_Screen_Molerus"
"Unit_Screen_Multideck"
"Unit_Screen_Plitt"
"Unit_Screen_Probability"
"Unit_Screen_Teipel"
"Unit_Splitter"
"Unit_TimeDelay_NormBased"
"Unit_TimeDelay_SimpleShift"
"Process_Agglomeration"
"Process_Comminution"
"Process_Granulation"
"Process_SieveMill"
)
FOREACH(test ${TESTS})
SET(CURRENT_TEST ${test})
CONFIGURE_FILE("${CMAKE_SOURCE_DIR}/tests/${CURRENT_TEST}/script.txt" "${CMAKE_BINARY_DIR}/tests/${CURRENT_TEST}/script.txt")
ADD_TEST(NAME ${CURRENT_TEST}_run
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
COMMAND ${CMAKE_BINDIR}/DyssolC --script=${CMAKE_BINARY_DIR}/tests/${CURRENT_TEST}/script.txt
)
IF(NOT CMAKE_BUILD_TYPE MATCHES Debug)
FILE(READ ${CMAKE_SOURCE_DIR}/tests/${CURRENT_TEST}/tolerance TOLERANCE)
ADD_TEST(NAME ${CURRENT_TEST}_diff
COMMAND python3 ${CMAKE_SOURCE_DIR}/tests/compare.py "${CMAKE_SOURCE_DIR}/tests/${CURRENT_TEST}/ideal.res" "${CMAKE_BINARY_DIR}/tests/${CURRENT_TEST}/real.res" -t ${TOLERANCE}
)
# _diff tests can only be run when the _run test is done
SET_TESTS_PROPERTIES(${CURRENT_TEST}_diff PROPERTIES DEPENDS ${CURRENT_TEST}_run)
ENDIF(NOT CMAKE_BUILD_TYPE MATCHES Debug)
ENDFOREACH(test ${TESTS})
ENDIF()
##################################################
### Documentation
IF(BUILD_DOCS)
#=================================================
#== Doxygen
FIND_PACKAGE(Doxygen)
# List of all API headers
SET(API_FILE_NAMES
"ModelsAPI/BaseUnit"
"ModelsAPI/ChemicalReaction"
"ModelsAPI/DenseMDMatrix"
"ModelsAPI/DistributionsFunctions"
"ModelsAPI/Holdup"
"ModelsAPI/Matrix2D"
"ModelsAPI/PlotManager"
"ModelsAPI/StateVariable"
"ModelsAPI/Stream"
"ModelsAPI/TransformMatrix"
"ModelsAPI/UnitParameters"
"ModelsAPI/UnitPorts"
"BaseSolvers/AgglomerationSolver"
"BaseSolvers/BaseSolver"
"Utilities/DyssolDefines"
)
# Gather all API headers
FOREACH(FILENAME ${API_FILE_NAMES})
FILE(GLOB_RECURSE HEADER ${CMAKE_SOURCE_DIR}/${FILENAME}.h)
LIST(APPEND API_HEADERS ${HEADER})
ENDFOREACH(FILENAME ${API_FILE_NAMES})
# Format the list for Doxygen file
STRING(REPLACE ";" "\" \"" API_HEADERS_LIST "${API_HEADERS}")
# Setup Doxygen variables
SET(DOXYGEN_INPUT_LIST ${API_HEADERS_LIST})
SET(DOXYGEN_OUTPUT_DIR ${CMAKE_BINARY_DIR}/doc/doxygen)
SET(DOXYGEN_OUTPUT_XML_DIR ${DOXYGEN_OUTPUT_DIR}/xml)
SET(DOXYGEN_INDEX_FILE ${DOXYGEN_OUTPUT_XML_DIR}/index.xml)
SET(DOXYFILE_IN ${CMAKE_SOURCE_DIR}/Documentation/Doxyfile.in)
SET(DOXYFILE_OUT ${CMAKE_BINARY_DIR}/Doxyfile)
# Replace variables inside @@ with the current values
CONFIGURE_FILE(${DOXYFILE_IN} ${DOXYFILE_OUT} @ONLY)
# Create Doxygen output directory
FILE(MAKE_DIRECTORY ${DOXYGEN_OUTPUT_DIR})
# Build with Doxygen
ADD_CUSTOM_COMMAND(OUTPUT ${DOXYGEN_INDEX_FILE}
DEPENDS ${API_HEADERS}
COMMAND ${DOXYGEN_EXECUTABLE} ${DOXYFILE_OUT}
MAIN_DEPENDENCY ${DOXYFILE_OUT} ${DOXYFILE_IN}
COMMENT "Generating Doxygen files"
VERBATIM
)
ADD_CUSTOM_TARGET(doxygen DEPENDS ${DOXYGEN_INDEX_FILE})
#=================================================
#== Sphinx
FIND_PACKAGE(Sphinx)
SET(SPHINX_SOURCE_DIR ${CMAKE_SOURCE_DIR}/Documentation/)
SET(SPHINX_BUILD ${CMAKE_BINARY_DIR}/doc/sphinx/_build/html)
SET(SPHINX_INDEX_FILE ${SPHINX_BUILD}/index.html)
SET(SPHINX_CONFIG_IN ${SPHINX_SOURCE_DIR}/conf.py.in)
SET(SPHINX_CONFIG_OUT ${SPHINX_SOURCE_DIR}/conf.py)
# Replace variables inside @@ with the current values
CONFIGURE_FILE(${SPHINX_CONFIG_IN} ${SPHINX_CONFIG_OUT} @ONLY)
ADD_CUSTOM_COMMAND(OUTPUT ${SPHINX_INDEX_FILE}
COMMAND ${SPHINX_EXECUTABLE} -b linkcheck ${SPHINX_SOURCE_DIR} ${SPHINX_BUILD} # Check links
COMMAND ${SPHINX_EXECUTABLE} -b html -Dbreathe_projects.Dyssol=${DOXYGEN_OUTPUT_XML_DIR} ${SPHINX_SOURCE_DIR} ${SPHINX_BUILD}
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
DEPENDS ${SPHINX_SOURCE_DIR}/index.rst ${DOXYGEN_INDEX_FILE}
MAIN_DEPENDENCY ${SPHINX_SOURCE_DIR}/conf.py
COMMENT "Generating documentation with Sphinx"
)
ADD_CUSTOM_TARGET(sphinx DEPENDS ${SPHINX_INDEX_FILE})
ADD_CUSTOM_TARGET(doc DEPENDS sphinx)
# Add an install target to install the docs
INSTALL(DIRECTORY ${SPHINX_BUILD}
DESTINATION ${INSTALL_DOCS_PATH}/sphinx/
)
ENDIF()