forked from usgs-coupled/phreeqc3
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
326 lines (295 loc) · 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
cmake_minimum_required(VERSION 3.3)
project(phreeqc)
# overide docdir on windows
if(WIN32 AND NOT CMAKE_INSTALL_DOCDIR)
set(CMAKE_INSTALL_DOCDIR "" CACHE PATH "documentation root (doc)")
set(CMAKE_INSTALL_DOCDIR "doc")
endif()
include(GNUInstallDirs)
set(phreeqc_SOURCES
src/ChartHandler.cpp
src/ChartObject.cpp
src/CurveObject.cpp
src/Dictionary.cpp
src/Dictionary.h
src/ExchComp.cxx
src/ExchComp.h
src/Exchange.cxx
src/Exchange.h
src/GasComp.cxx
src/GasComp.h
src/GasPhase.cxx
src/GasPhase.h
src/ISolution.cxx
src/ISolution.h
src/ISolutionComp.cxx
src/ISolutionComp.h
src/KineticsComp.cxx
src/KineticsComp.h
src/NA.h
src/NameDouble.cxx
src/NameDouble.h
src/NumKeyword.cxx
src/NumKeyword.h
src/PBasic.cpp
src/PBasic.h
src/PHRQ_io_output.cpp
src/PPassemblage.cxx
src/PPassemblage.h
src/PPassemblageComp.cxx
src/PPassemblageComp.h
src/Phreeqc.cpp
src/Phreeqc.h
src/PhreeqcKeywords/Keywords.cpp
src/PhreeqcKeywords/Keywords.h
src/Pressure.cxx
src/Pressure.h
src/Reaction.cxx
src/Reaction.h
src/ReadClass.cxx
src/SS.cxx
src/SS.h
src/SSassemblage.cxx
src/SSassemblage.h
src/SScomp.cxx
src/SScomp.h
src/SelectedOutput.cpp
src/SelectedOutput.h
src/Serializer.cxx
src/Serializer.h
src/Solution.cxx
src/Solution.h
src/SolutionIsotope.cxx
src/SolutionIsotope.h
src/StorageBin.cxx
src/StorageBin.h
src/StorageBinList.cpp
src/StorageBinList.h
src/Surface.cxx
src/Surface.h
src/SurfaceCharge.cxx
src/SurfaceCharge.h
src/SurfaceComp.cxx
src/SurfaceComp.h
src/System.cxx
src/System.h
src/Temperature.cxx
src/Temperature.h
src/Use.cpp
src/Use.h
src/UserPunch.cpp
src/UserPunch.h
src/advection.cpp
src/basicsubs.cpp
src/cl1.cpp
src/class_main.cpp
src/common/PHRQ_base.cxx
src/common/PHRQ_base.h
src/common/PHRQ_io.cpp
src/common/PHRQ_io.h
src/common/Parser.cxx
src/common/Parser.h
src/common/Utils.cxx
src/common/Utils.h
src/common/phrqtype.h
src/cvdense.cpp
src/cvdense.h
src/cvode.cpp
src/cvode.h
src/cxxKinetics.cxx
src/cxxKinetics.h
src/cxxMix.cxx
src/cxxMix.h
src/dense.cpp
src/dense.h
src/dumper.cpp
src/dumper.h
src/gases.cpp
src/global_structures.h
src/input.cpp
src/integrate.cpp
src/inverse.cpp
src/isotopes.cpp
src/kinetics.cpp
src/mainsubs.cpp
src/model.cpp
src/nvector.cpp
src/nvector.h
src/nvector_serial.cpp
src/nvector_serial.h
src/parse.cpp
src/phqalloc.cpp
src/phqalloc.h
src/pitzer.cpp
src/pitzer_structures.cpp
src/prep.cpp
src/print.cpp
src/read.cpp
src/readtr.cpp
src/runner.cpp
src/runner.h
src/sit.cpp
src/smalldense.cpp
src/smalldense.h
src/spread.cpp
src/step.cpp
src/structures.cpp
src/sundialsmath.cpp
src/sundialsmath.h
src/sundialstypes.h
src/tally.cpp
src/tidy.cpp
src/transport.cpp
src/utilities.cpp
)
option(PHRQC_USE_GMP "Use GNU Multiple Precision library" OFF)
if(PHRQC_USE_GMP)
find_path(GMP_INCLUDE_PATH gmp.h)
find_library(GMP_LIBRARY gmp)
else()
mark_as_advanced(FORCE GMP_INCLUDE_PATH GMP_LIBRARY)
endif()
if(PHRQC_USE_GMP)
if(GMP_INCLUDE_PATH)
set(phreeqc_SOURCES ${phreeqc_SOURCES} src/cl1mp.cpp)
endif()
endif()
option(PHRQC_TESTING "Set TESTING preprocessor definition" OFF)
option(PHRQC_ENABLE_REGRESSION_TESTING "Enables all tests including tests that take over 600 seconds to run" OFF)
if(MSVC)
# Copy Release to ClrRelease
SET(CMAKE_CXX_FLAGS_CLRRELEASE ${CMAKE_CXX_FLAGS_RELEASE} CACHE STRING
"Flags used by the C++ compiler during ClrRelease builds."
FORCE)
SET(CMAKE_C_FLAGS_CLRRELEASE ${CMAKE_C_FLAGS_RELEASE} CACHE STRING
"Flags used by the C compiler during ClrRelease builds."
FORCE)
SET(CMAKE_EXE_LINKER_FLAGS_CLRRELEASE
${CMAKE_EXE_LINKER_FLAGS_RELEASE} CACHE STRING
"Flags used for linking binaries during ClrRelease builds."
FORCE)
SET(CMAKE_SHARED_LINKER_FLAGS_CLRRELEASE
${CMAKE_SHARED_LINKER_FLAGS_RELEASE} CACHE STRING
"Flags used by the shared libraries linker during ClrRelease builds."
FORCE)
MARK_AS_ADVANCED(
CMAKE_CXX_FLAGS_CLRRELEASE
CMAKE_C_FLAGS_CLRRELEASE
CMAKE_EXE_LINKER_FLAGS_CLRRELEASE
CMAKE_SHARED_LINKER_FLAGS_CLRRELEASE )
# Copy Debug to ClrDebug
SET(CMAKE_CXX_FLAGS_CLRDEBUG ${CMAKE_CXX_FLAGS_DEBUG} CACHE STRING
"Flags used by the C++ compiler during ClrDebug builds."
FORCE)
SET(CMAKE_C_FLAGS_CLRDEBUG ${CMAKE_C_FLAGS_DEBUG} CACHE STRING
"Flags used by the C compiler during ClrDebug builds."
FORCE)
SET(CMAKE_EXE_LINKER_FLAGS_CLRDEBUG
${CMAKE_EXE_LINKER_FLAGS_DEBUG} CACHE STRING
"Flags used for linking binaries during ClrDebug builds."
FORCE)
SET(CMAKE_SHARED_LINKER_FLAGS_CLRDEBUG
${CMAKE_SHARED_LINKER_FLAGS_DEBUG} CACHE STRING
"Flags used by the shared libraries linker during ClrDebug builds."
FORCE)
MARK_AS_ADVANCED(
CMAKE_CXX_FLAGS_CLRDEBUG
CMAKE_C_FLAGS_CLRDEBUG
CMAKE_EXE_LINKER_FLAGS_CLRDEBUG
CMAKE_SHARED_LINKER_FLAGS_CLRDEBUG )
# Remove /EHsc from CMAKE_CXX_FLAGS
STRING(REPLACE " /EHsc" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
STRING(REPLACE "/EHsc " "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
SET(CMAKE_CXX_FLAGS
"${CMAKE_CXX_FLAGS}" CACHE STRING
"Flags used by the compiler during all build types."
FORCE)
# Add /EHsc to CMAKE_CXX_FLAGS_RELEASE
STRING(REPLACE "/EHsc " "" CMAKE_CXX_FLAGS_RELEASE ${CMAKE_CXX_FLAGS_RELEASE})
STRING(REPLACE " /EHsc" "" CMAKE_CXX_FLAGS_RELEASE ${CMAKE_CXX_FLAGS_RELEASE})
SET(CMAKE_CXX_FLAGS_RELEASE
"/EHsc ${CMAKE_CXX_FLAGS_RELEASE}" CACHE STRING
"Flags used by the compiler during Release build types."
FORCE)
# Add /EHsc to CMAKE_CXX_FLAGS_DEBUG
STRING(REPLACE "/EHsc " "" CMAKE_CXX_FLAGS_DEBUG ${CMAKE_CXX_FLAGS_DEBUG})
STRING(REPLACE " /EHsc" "" CMAKE_CXX_FLAGS_DEBUG ${CMAKE_CXX_FLAGS_DEBUG})
SET(CMAKE_CXX_FLAGS_DEBUG
"/EHsc ${CMAKE_CXX_FLAGS_DEBUG}" CACHE STRING
"Flags used by the compiler during Debug build types."
FORCE)
# Add /EHa and /clr to CMAKE_CXX_FLAGS_CLRRELEASE
STRING(REPLACE "/EHsc " "" CMAKE_CXX_FLAGS_CLRRELEASE ${CMAKE_CXX_FLAGS_CLRRELEASE})
STRING(REPLACE " /EHsc" "" CMAKE_CXX_FLAGS_CLRRELEASE ${CMAKE_CXX_FLAGS_CLRRELEASE})
SET(CMAKE_CXX_FLAGS_CLRRELEASE
"-DMULTICHART /EHa ${CMAKE_CXX_FLAGS_CLRRELEASE} /clr" CACHE STRING
"Flags used by the compiler during ClrRelease builds."
FORCE)
# Add /EHa and /clr to CMAKE_CXX_FLAGS_CLRDEBUG
STRING(REPLACE "/EHsc " "" CMAKE_CXX_FLAGS_CLRDEBUG ${CMAKE_CXX_FLAGS_CLRDEBUG})
STRING(REPLACE " /EHsc" "" CMAKE_CXX_FLAGS_CLRDEBUG ${CMAKE_CXX_FLAGS_CLRDEBUG})
STRING(REPLACE " /RTC1" " " CMAKE_CXX_FLAGS_CLRDEBUG "${CMAKE_CXX_FLAGS_CLRDEBUG}")
STRING(REPLACE "/RTC1 " " " CMAKE_CXX_FLAGS_CLRDEBUG "${CMAKE_CXX_FLAGS_CLRDEBUG}")
SET(CMAKE_CXX_FLAGS_CLRDEBUG
"-DMULTICHART /EHa ${CMAKE_CXX_FLAGS_CLRDEBUG} /clr" CACHE STRING
"Flags used by the compiler during ClrDebug builds."
FORCE)
SET(CMAKE_CONFIGURATION_TYPES "Debug;Release;ClrDebug;ClrRelease" CACHE STRING
"Semicolon separated list of supported configuration types."
FORCE)
endif()
add_executable(phreeqc ${phreeqc_SOURCES})
set_target_properties(phreeqc PROPERTIES DEBUG_POSTFIX "d")
target_compile_features(phreeqc PUBLIC cxx_std_11)
# Add '#define TESTING'
if(PHRQC_TESTING)
target_compile_definitions(phreeqc PRIVATE TESTING)
endif()
# force utf-8 on VS2015 and later
if(MSVC_VERSION GREATER_EQUAL 1900)
# https://learn.microsoft.com/en-us/cpp/preprocessor/predefined-macros?view=msvc-170
target_compile_options(phreeqc PRIVATE "$<$<C_COMPILER_ID:MSVC>:/utf-8>")
target_compile_options(phreeqc PRIVATE "$<$<CXX_COMPILER_ID:MSVC>:/utf-8>")
endif()
# Disable deprecation warnings for standard C and STL functions in VS2005
# and later
if(MSVC_VERSION EQUAL 1400 OR MSVC_VERSION GREATER 1400)
target_compile_definitions(phreeqc PRIVATE _CRT_SECURE_NO_DEPRECATE)
target_compile_definitions(phreeqc PRIVATE _SCL_SECURE_NO_WARNINGS)
endif()
# define DOS
if(WIN32)
target_compile_definitions(phreeqc PRIVATE DOS)
target_compile_definitions(phreeqc PRIVATE _CONSOLE)
endif()
target_include_directories(phreeqc PRIVATE "${PROJECT_SOURCE_DIR}/src")
target_include_directories(phreeqc PRIVATE "${PROJECT_SOURCE_DIR}/src/common")
target_include_directories(phreeqc PRIVATE "${PROJECT_SOURCE_DIR}/src/PhreeqcKeywords")
if(PHRQC_USE_GMP)
if(GMP_INCLUDE_PATH)
target_compile_definitions(phreeqc PRIVATE INVERSE_CL1MP)
target_include_directories(phreeqc PRIVATE "${GMP_INCLUDE_PATH}")
endif()
if(GMP_LIBRARY)
target_link_libraries(phreeqc ${GMP_LIBRARY})
endif()
endif()
if(WIN32)
install(TARGETS phreeqc DESTINATION "${CMAKE_INSTALL_BINDIR}/Release" CONFIGURATIONS Debug Release)
install(TARGETS phreeqc DESTINATION "${CMAKE_INSTALL_BINDIR}/ClrRelease" CONFIGURATIONS ClrDebug ClrRelease)
else()
install(TARGETS phreeqc DESTINATION "${CMAKE_INSTALL_BINDIR}")
endif()
# tests
include(CTest)
# subdirectories
add_subdirectory(database)
add_subdirectory(doc)
add_subdirectory(examples)
if(EXISTS ${CMAKE_CURRENT_LIST_DIR}/mytest/CMakeLists.txt)
add_subdirectory(mytest)
endif()
# Setup references for /CLR
if(MSVC)
set_target_properties(phreeqc PROPERTIES VS_DOTNET_REFERENCES "System;System.Drawing;System.Windows.Forms;${CMAKE_CURRENT_SOURCE_DIR}/src/ZedGraph.dll")
endif()