-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathCMakeLists.txt
298 lines (278 loc) · 10.7 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
# Required CMake arguments
cmake_minimum_required(VERSION 3.20)
#set standard
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_TRY_COMPILE_TARGET_TYPE "STATIC_LIBRARY") #needed for testing cross compilation see: https://stackoverflow.com/questions/53633705/cmake-the-c-compiler-is-not-able-to-compile-a-simple-test-program
#set(parallel ON) # currently set through -Dparallel, but can be manually set by uncommenting
set(cxx_flags "-O2") #release mode overwrites with "-O3"
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_VERBOSE_MAKEFILE ON)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${cxx_flags}") # -O2 appears to be the fastest option
set(CMAKE_INCLUDE_CURRENT_DIR ON)
#set compiler if necessary, this has to be done before project()
#set (CMAKE_CXX_COMPILER <specify compiler here>)
#if(CMAKE_CXX_COMPILER_LOADED)
# message(STATUS "Configured for C++, with compiler: ")
# message(STATUS "${CMAKE_CXX_COMPILER_VERSION}}")
#endif()
#################### BELOW SPECIFIES COMPILATION FOR SERIAL OR PARALLEL VERSION OF TRIBS ###############################
if(parallel)
set(exe "tRIBSpar")
project(${exe}
DESCRIPTION "Parallel Distribution of the TIN-based Real-time Integrated Basin Simulator Distributed Hydrological Model"
VERSION 5.2.0
)
add_executable(${exe} src/main.cpp)
message(WARNING "Compiling parallel version of tRIBS")
target_compile_definitions(${exe}
PRIVATE
PARALLEL_TRIBS
PRIVATE
GRAPH_TRIBS
PRIVATE
LINUX_32
)
find_package(MPI REQUIRED) #Note: changes to MPI path etc may require reset of CMakeCache.txt
if (MPI_FOUND) #Note:this should find whichever implementation of MPI is installed (i.e. Open MPI, Intel, mpich)
include_directories(${MPI_INCLUDE_PATH})
target_link_libraries(${exe} PUBLIC MPI::MPI_CXX)
set(CMAKE_CXX_COMPILER mpicxx)
else (MPI_FOUND)
message(SEND_ERROR "This application cannot compile without MPI")
endif (MPI_FOUND)
target_sources(
${exe} PRIVATE src/main.cpp
src/Headers/Classes.h
src/Headers/Definitions.h
src/Headers/Inclusions.h
src/Headers/TemplDefinitions.h
src/Headers/globalFns.cpp
src/Headers/globalFns.h
src/Headers/globalIO.h
src/Mathutil/geometry.h
src/Mathutil/mathutil.cpp
src/Mathutil/mathutil.h
src/Mathutil/predicates.cpp
src/Mathutil/predicates.h
src/tArray/tArray.h
src/tArray/tMatrix.cpp
src/tArray/tMatrix.h
src/tCNode/tCNode.cpp
src/tCNode/tCNode.h
src/tFlowNet/tFlowNet.cpp
src/tFlowNet/tFlowNet.h
src/tFlowNet/tFlowResults.cpp
src/tFlowNet/tFlowResults.h
src/tFlowNet/tKinemat.cpp
src/tFlowNet/tKinemat.h
src/tFlowNet/tResData.cpp
src/tFlowNet/tResData.h
src/tFlowNet/tReservoir.cpp
src/tFlowNet/tReservoir.h
src/tGraph/tGraph.cpp
src/tGraph/tGraph.h
src/tGraph/tGraphNode.cpp
src/tGraph/tGraphNode.h
src/tHydro/tEvapoTrans.cpp
src/tHydro/tEvapoTrans.h
src/tHydro/tHydroMet.cpp
src/tHydro/tHydroMet.h
src/tHydro/tHydroMetConvert.cpp
src/tHydro/tHydroMetConvert.h
src/tHydro/tHydroMetStoch.cpp
src/tHydro/tHydroMetStoch.h
src/tHydro/tHydroModel.cpp
src/tHydro/tHydroModel.h
src/tHydro/tIntercept.cpp
src/tHydro/tIntercept.h
src/tHydro/tSnowPack.cpp
src/tHydro/tSnowPack.h
src/tHydro/tWaterBalance.cpp
src/tHydro/tWaterBalance.h
src/tInOut/tInputFile.cpp
src/tInOut/tInputFile.h
src/tInOut/tOstream.cpp
src/tInOut/tOstream.h
src/tInOut/tOutput.cpp
src/tInOut/tOutput.h
src/tList/tList.cpp
src/tList/tList.h
src/tListInputData/tListInputData.cpp
src/tListInputData/tListInputData.h
src/tMesh/heapsort.h
src/tMesh/tMesh.cpp
src/tMesh/tMesh.h
src/tMesh/tTriangulator.cpp
src/tMesh/tTriangulator.h
src/tMeshElements/meshElements.cpp
src/tMeshElements/meshElements.h
src/tMeshList/tMeshList.h
src/tParallel/tParallel.cpp
src/tParallel/tParallel.h
src/tParallel/tTimer.cpp
src/tParallel/tTimer.h
src/tParallel/tTimings.cpp
src/tParallel/tTimings.h
src/tPtrList/tPtrList.cpp
src/tPtrList/tPtrList.h
src/tRasTin/tInvariant.cpp
src/tRasTin/tInvariant.h
src/tRasTin/tRainGauge.cpp
src/tRasTin/tRainGauge.h
src/tRasTin/tRainfall.cpp
src/tRasTin/tRainfall.h
src/tRasTin/tResample.cpp
src/tRasTin/tResample.h
src/tRasTin/tShelter.cpp
src/tRasTin/tShelter.h
src/tRasTin/tVariant.cpp
src/tRasTin/tVariant.h
src/tSimulator/tControl.cpp
src/tSimulator/tControl.h
src/tSimulator/tPreProcess.cpp
src/tSimulator/tPreProcess.h
src/tSimulator/tRestart.cpp
src/tSimulator/tRestart.h
src/tSimulator/tRunTimer.cpp
src/tSimulator/tRunTimer.h
src/tSimulator/tSimul.cpp
src/tSimulator/tSimul.h
src/tStorm/tStorm.cpp
src/tStorm/tStorm.h
)
else()
set(exe "tRIBS")
project(${exe}
DESCRIPTION "Serial Distribution of the TIN-based Real-time Integrated Basin Simulator Distributed Hydrological Model"
VERSION 5.2.0)
add_executable(${exe} src/main.cpp)
message(WARNING "Compiling serial version of tRIBS")
if(APPLE) # not sure though if loading libraries are any different for linux--windows don't know
target_compile_definitions(${exe}
PRIVATE
MAC
)
else()
target_compile_definitions(${exe}
PRIVATE
LINUX_32
)
endif()
target_sources(
${exe} PRIVATE src/main.cpp
src/Headers/Classes.h
src/Headers/Definitions.h
src/Headers/Inclusions.h
src/Headers/TemplDefinitions.h
src/Headers/globalFns.cpp
src/Headers/globalFns.h
src/Headers/globalIO.h
src/Mathutil/geometry.h
src/Mathutil/mathutil.cpp
src/Mathutil/mathutil.h
src/Mathutil/predicates.cpp
src/Mathutil/predicates.h
src/tArray/tArray.h
src/tArray/tMatrix.cpp
src/tArray/tMatrix.h
src/tCNode/tCNode.cpp
src/tCNode/tCNode.h
src/tFlowNet/tFlowNet.cpp
src/tFlowNet/tFlowNet.h
src/tFlowNet/tFlowResults.cpp
src/tFlowNet/tFlowResults.h
src/tFlowNet/tKinemat.cpp
src/tFlowNet/tKinemat.h
src/tFlowNet/tResData.cpp
src/tFlowNet/tResData.h
src/tFlowNet/tReservoir.cpp
src/tFlowNet/tReservoir.h
src/tGraph/tGraph.cpp
src/tGraph/tGraph.h
src/tGraph/tGraphNode.cpp
src/tGraph/tGraphNode.h
src/tHydro/tEvapoTrans.cpp
src/tHydro/tEvapoTrans.h
src/tHydro/tHydroMet.cpp
src/tHydro/tHydroMet.h
src/tHydro/tHydroMetConvert.cpp
src/tHydro/tHydroMetConvert.h
src/tHydro/tHydroMetStoch.cpp
src/tHydro/tHydroMetStoch.h
src/tHydro/tHydroModel.cpp
src/tHydro/tHydroModel.h
src/tHydro/tIntercept.cpp
src/tHydro/tIntercept.h
src/tHydro/tSnowPack.cpp
src/tHydro/tSnowPack.h
src/tHydro/tWaterBalance.cpp
src/tHydro/tWaterBalance.h
src/tInOut/tInputFile.cpp
src/tInOut/tInputFile.h
src/tInOut/tOstream.cpp
src/tInOut/tOstream.h
src/tInOut/tOutput.cpp
src/tInOut/tOutput.h
src/tList/tList.cpp
src/tList/tList.h
src/tListInputData/tListInputData.cpp
src/tListInputData/tListInputData.h
src/tMesh/heapsort.h
src/tMesh/tMesh.cpp
src/tMesh/tMesh.h
src/tMesh/tTriangulator.cpp
src/tMesh/tTriangulator.h
src/tMeshElements/meshElements.cpp
src/tMeshElements/meshElements.h
src/tMeshList/tMeshList.h
src/tPtrList/tPtrList.cpp
src/tPtrList/tPtrList.h
src/tRasTin/tInvariant.cpp
src/tRasTin/tInvariant.h
src/tRasTin/tRainGauge.cpp
src/tRasTin/tRainGauge.h
src/tRasTin/tRainfall.cpp
src/tRasTin/tRainfall.h
src/tRasTin/tResample.cpp
src/tRasTin/tResample.h
src/tRasTin/tShelter.cpp
src/tRasTin/tShelter.h
src/tRasTin/tVariant.cpp
src/tRasTin/tVariant.h
src/tSimulator/tControl.cpp
src/tSimulator/tControl.h
src/tSimulator/tPreProcess.cpp
src/tSimulator/tPreProcess.h
src/tSimulator/tRestart.cpp
src/tSimulator/tRestart.h
src/tSimulator/tRunTimer.cpp
src/tSimulator/tRunTimer.h
src/tSimulator/tSimul.cpp
src/tSimulator/tSimul.h
src/tStorm/tStorm.cpp
src/tStorm/tStorm.h
)
endif()
# can be passed via the command line with -Dpackaging=ON
#set(packaging ON)
if (packaging)
if (NOT DEFINED os)
set(os "macOS/Silicon") # options: macOS/Silicon, macOS/Intel, or Linux
endif ()
install(
TARGETS ${PROJECT_NAME}
)
set(CPACK_VERBOSE ON)
set(CPACK_PACKAGE_NAME "TIN-based Real-time Integrated Basin Simulator")
set(CPACK_PACKAGE_FILE_NAME "TIN-based Real-time Integrated Basin Simulator-5.2.0")
set(CPACK_PACKAGE_VENDOR "tRIBS developers")
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_LIST_DIR}/LICENSE.txt")
# Set the custom script for the STGZ generator
#list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/packaging/utilities/CPack.STGZ_Header.sh.in")
#set(CPACK_STGZ_HEADER_FILE "${CMAKE_SOURCE_DIR}/packaging/utilities/CPack.STGZ_Header.sh.in")
set(CPACK_GENERATOR "STGZ")
set(CPACK_PACKAGE_DIRECTORY "${CMAKE_SOURCE_DIR}/packaging/${os}")
set(CPACK_OUTPUT_FILE_PREFIX "${CMAKE_SOURCE_DIR}/packaging/${os}")
include(CPack)
cpack_add_component(CPACK_COMPONENTS_ALL)
endif ()