-
Notifications
You must be signed in to change notification settings - Fork 2
/
CMakeLists.txt
455 lines (444 loc) · 11.5 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
# CMakeList.txt : CMake project for OpenDSSX, include source and define
# project specific logic here.
#
cmake_minimum_required (VERSION 3.15)
project("OpenDSSX" VERSION 0.0.0 DESCRIPTION "OpenDSS-X")
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
find_package(Threads)
add_subdirectory(klusolve EXCLUDE_FROM_ALL)
set_target_properties(klusolve_all PROPERTIES
RUNTIME_OUTPUT_DIRECTORY ".."
)
# Use this variable to define what type of output will be generated by the compiler
if(NOT DEFINED MyOutputType)
# Allow defining MyOutputType in scripts/CLI.
# TODO: move to a cached variable later (avoid that so we don't need to update build docs yet)
set(MyOutputType "EXE") # Output type, DLL or EXE
endif()
if(MyOutputType STREQUAL "EXE")
add_executable(OpenDSSC
CMD/OpenDSSC.cpp
Support/d2c_system.cpp
Support/d2c_syscurr.cpp
Support/d2c_sysstring.cpp
Support/d2c_sysmath.cpp
Support/d2c_sysdate.cpp
Support/d2c_sysexcept.cpp
Support/d2c_sysfile.cpp
Support/Sysutils.cpp
Support/d2c_structures.cpp
Shared/Arraydef.cpp
Shared/CktTree.cpp
Shared/Command.cpp
Shared/Dynamics.cpp
Shared/InvDynamics.cpp
Shared/HashList.cpp
Shared/IniRegSave.cpp
Shared/LineUnits.cpp
Shared/mathutil.cpp
Shared/PointerList.cpp
Shared/Pstcalc.cpp
Shared/StackDef.cpp
Shared/Ucmatrix.cpp
Shared/Ucomplex.cpp
Parser/RPN.cpp
Parser/ParserDel.cpp
Common/AutoAdd.cpp
Common/Bus.cpp
Common/Circuit.cpp
Common/CktElement.cpp
Common/Conductor.cpp
Common/CktElementClass.cpp
Common/ControlQueue.cpp
Common/Diakoptics.cpp
Common/DSSCallBackRoutines.cpp
Common/DSSClass.cpp
Common/DSSClassDefs.cpp
Common/DSSGlobals.cpp
Common/ExportCIMXML.cpp
Common/ExportResults.cpp
Common/Feeder.cpp
Common/MeTIS_Exec.cpp
Common/ShowResults.cpp
Common/Solution.cpp
Common/SolutionAlgs.cpp
Common/Sparse_Math.cpp
Common/Terminal.cpp
Common/Utilities.cpp
Common/YMatrix.cpp
Forms/CmdForms.cpp
GISCommands/GISCommands.cpp
Executive/ConnectOptions.cpp
Executive/ExecCommands.cpp
Executive/ExecHelper.cpp
Executive/ExecOptions.cpp
Executive/Executive.cpp
Executive/ExportOptions.cpp
Executive/ShowOptions.cpp
Executive/PlotOptions.cpp
Meters/MeterClass.cpp
Meters/EnergyMeter.cpp
Meters/fMonitor.cpp
Meters/LD_fm_infos.cpp
Meters/MemoryMap_lib.cpp
Meters/MeterElement.cpp
Meters/Monitor.cpp
Meters/ReduceAlgs.cpp
Meters/Sensor.cpp
Meters/VLNodeVars.cpp
Controls/CapControl.cpp
Controls/CapControlVars.cpp
Controls/CapUserControl.cpp
Controls/ControlClass.cpp
Controls/ControlElem.cpp
Controls/ESPVLControl.cpp
Controls/ExpControl.cpp
Controls/GenDispatcher.cpp
Controls/InvControl.cpp
Controls/Recloser.cpp
Controls/RegControl.cpp
Controls/Relay.cpp
Controls/StorageController.cpp
Controls/SwtControl.cpp
Controls/UPFCControl.cpp
PCElements/Equivalent.cpp
PCElements/generator.cpp
PCElements/GeneratorVars.cpp
PCElements/Generic5OrderMach.cpp
PCElements/GenUserModel.cpp
PCElements/GICLine.cpp
PCElements/GICsource.cpp
PCElements/IndMach012.cpp
PCElements/Isource.cpp
PCElements/Load.cpp
PCElements/PCClass.cpp
PCElements/PCElement.cpp
PCElements/PVsystem.cpp
PCElements/PVSystemUserModel.cpp
PCElements/Storage.cpp
PCElements/StorageVars.cpp
PCElements/StoreUserModel.cpp
PCElements/UPFC.cpp
PCElements/vccs.cpp
PCElements/VSConverter.cpp
PCElements/VSource.cpp
PCElements/WindGen.cpp
PCElements/WindGenUserModel.cpp
PCElements/WindGenVars.cpp
PDElements/AutoTrans.cpp
PDElements/Capacitor.cpp
PDElements/Fault.cpp
PDElements/fuse.cpp
PDElements/GICTransformer.cpp
PDElements/Line.cpp
PDElements/PDClass.cpp
PDElements/PDElement.cpp
PDElements/Reactor.cpp
PDElements/Transformer.cpp
General/CableConstants.cpp
General/CableData.cpp
General/CNData.cpp
General/CNLineConstants.cpp
General/ConductorData.cpp
General/DSSObject.cpp
General/DynamicExp.cpp
General/GrowthShape.cpp
General/LineCode.cpp
General/LineConstants.cpp
General/LineGeometry.cpp
General/LineSpacing.cpp
General/LoadShape.cpp
General/NamedObject.cpp
General/OHLineConstants.cpp
General/PriceShape.cpp
General/Spectrum.cpp
General/TCC_Curve.cpp
General/TempShape.cpp
General/TSData.cpp
General/TSLineConstants.cpp
General/WireData.cpp
General/XfmrCode.cpp
General/XYcurve.cpp
PCElements/PCElement.cpp
MyOpenDSS/MyDSSClassDefs.cpp
GenModels/gencls.cpp
GenModels/genrou.cpp
GenControls/Exciter/ExcSexs.cpp
GenControls/Governor/tgov.cpp
#Shared/IntegrationMethods.cpp
Plot/DSSPlot.cpp
Plot/DSSGraph.cpp
)
else()
add_library(OpenDSSC SHARED
DLL/OpenDSSCDLL.cpp
Support/d2c_system.cpp
Support/d2c_syscurr.cpp
Support/d2c_sysstring.cpp
Support/d2c_sysmath.cpp
Support/d2c_sysdate.cpp
Support/d2c_sysexcept.cpp
Support/d2c_sysfile.cpp
Support/Sysutils.cpp
Support/d2c_structures.cpp
Shared/Arraydef.cpp
Shared/CktTree.cpp
Shared/Command.cpp
Shared/Dynamics.cpp
Shared/InvDynamics.cpp
Shared/HashList.cpp
Shared/IniRegSave.cpp
Shared/LineUnits.cpp
Shared/mathutil.cpp
Shared/PointerList.cpp
Shared/Pstcalc.cpp
Shared/StackDef.cpp
Shared/Ucmatrix.cpp
Shared/Ucomplex.cpp
Parser/RPN.cpp
Parser/ParserDel.cpp
Common/AutoAdd.cpp
Common/Bus.cpp
Common/Circuit.cpp
Common/CktElement.cpp
Common/Conductor.cpp
Common/CktElementClass.cpp
Common/ControlQueue.cpp
Common/Diakoptics.cpp
Common/DSSCallBackRoutines.cpp
Common/DSSClass.cpp
Common/DSSClassDefs.cpp
Common/DSSGlobals.cpp
Common/ExportCIMXML.cpp
Common/ExportResults.cpp
Common/Feeder.cpp
Common/MeTIS_Exec.cpp
Common/ShowResults.cpp
Common/Solution.cpp
Common/SolutionAlgs.cpp
Common/Sparse_Math.cpp
Common/Terminal.cpp
Common/Utilities.cpp
Common/YMatrix.cpp
Forms/CmdForms.cpp
GISCommands/GISCommands.cpp
Executive/ConnectOptions.cpp
Executive/ExecCommands.cpp
Executive/ExecHelper.cpp
Executive/ExecOptions.cpp
Executive/Executive.cpp
Executive/ExportOptions.cpp
Executive/ShowOptions.cpp
Executive/PlotOptions.cpp
Meters/MeterClass.cpp
Meters/EnergyMeter.cpp
Meters/fMonitor.cpp
Meters/LD_fm_infos.cpp
Meters/MemoryMap_lib.cpp
Meters/MeterElement.cpp
Meters/Monitor.cpp
Meters/ReduceAlgs.cpp
Meters/Sensor.cpp
Meters/VLNodeVars.cpp
Controls/CapControl.cpp
Controls/CapControlVars.cpp
Controls/CapUserControl.cpp
Controls/ControlClass.cpp
Controls/ControlElem.cpp
Controls/ESPVLControl.cpp
Controls/ExpControl.cpp
Controls/GenDispatcher.cpp
Controls/InvControl.cpp
Controls/Recloser.cpp
Controls/RegControl.cpp
Controls/Relay.cpp
Controls/StorageController.cpp
Controls/SwtControl.cpp
Controls/UPFCControl.cpp
PCElements/Equivalent.cpp
PCElements/generator.cpp
PCElements/GeneratorVars.cpp
PCElements/Generic5OrderMach.cpp
PCElements/GenUserModel.cpp
PCElements/GICLine.cpp
PCElements/GICsource.cpp
PCElements/IndMach012.cpp
PCElements/Isource.cpp
PCElements/Load.cpp
PCElements/PCClass.cpp
PCElements/PCElement.cpp
PCElements/PVsystem.cpp
PCElements/PVSystemUserModel.cpp
PCElements/Storage.cpp
PCElements/StorageVars.cpp
PCElements/StoreUserModel.cpp
PCElements/UPFC.cpp
PCElements/vccs.cpp
PCElements/VSConverter.cpp
PCElements/VSource.cpp
PCElements/WindGen.cpp
PCElements/WindGenUserModel.cpp
PCElements/WindGenVars.cpp
PDElements/AutoTrans.cpp
PDElements/Capacitor.cpp
PDElements/Fault.cpp
PDElements/fuse.cpp
PDElements/GICTransformer.cpp
PDElements/Line.cpp
PDElements/PDClass.cpp
PDElements/PDElement.cpp
PDElements/Reactor.cpp
PDElements/Transformer.cpp
General/CableConstants.cpp
General/CableData.cpp
General/CNData.cpp
General/CNLineConstants.cpp
General/ConductorData.cpp
General/DSSObject.cpp
General/DynamicExp.cpp
General/GrowthShape.cpp
General/LineCode.cpp
General/LineConstants.cpp
General/LineGeometry.cpp
General/LineSpacing.cpp
General/LoadShape.cpp
General/NamedObject.cpp
General/OHLineConstants.cpp
General/PriceShape.cpp
General/Spectrum.cpp
General/TCC_Curve.cpp
General/TempShape.cpp
General/TSData.cpp
General/TSLineConstants.cpp
General/WireData.cpp
General/XfmrCode.cpp
General/XYcurve.cpp
PCElements/PCElement.cpp
MyOpenDSS/MyDSSClassDefs.cpp
GenModels/gencls.cpp
GenModels/genrou.cpp
GenControls/Exciter/ExcSexs.cpp
GenControls/Governor/tgov.cpp
#Shared/IntegrationMethods.cpp
Plot/DSSPlot.cpp
Plot/DSSGraph.cpp
)
endif()
target_compile_options(OpenDSSC PRIVATE
$<$<CXX_COMPILER_ID:MSVC>:
# Options for MSVC:
/permissive-
>
$<$<OR:$<CXX_COMPILER_ID:Clang>,$<CXX_COMPILER_ID:GNU>>:
# Options for Clang or GCC:
# -fms-extensions
$<$<CONFIG:Debug>:
-Wall
-Wextra
# These are temporarilly disabled:
-Wno-unused-variable
-Wno-unused-parameter
-Wno-sign-compare
-Wno-unused-private-field
-Wno-unused-const-variable
# Options for Clang-only:
$<$<CXX_COMPILER_ID:Clang>:
# Purposefully fill uninitialized variables with a pattern, to help catch errors faster:
-ftrivial-auto-var-init=pattern
# Enable Clang's Address Sanitizer: https://clang.llvm.org/docs/AddressSanitizer.html
-fsanitize=address
$<$<VERSION_GREATER_EQUAL:${CMAKE_CXX_COMPILER_VERSION},13.0.0>:
-fsanitize-address-use-after-return=always
>
-fsanitize-address-use-after-scope
# Strive for understandable stack traces by disabling a few optimizations:
-fno-omit-frame-pointer
-fno-inline-functions
-fno-optimize-sibling-calls
>
>
>
)
target_link_options(OpenDSSC PRIVATE
$<$<CXX_COMPILER_ID:Clang>:
$<$<CONFIG:Debug>:
# Clang's Address Sanitizer also needs this link switch: https://clang.llvm.org/docs/AddressSanitizer.html
# -fsanitize=address
>
>
)
target_compile_features(OpenDSSC PUBLIC
# Require C11 support when we're compiling C code.
c_std_11
# Require C++11 for std::filesystem. (If C++11 support is needed, use Boost.)
cxx_std_11
)
# Disallowing extensions would help check the code for compatibility with other compilers:
#set_property(OpenDSSC tgt PROPERTY CXX_EXTENSIONS OFF)
if(MSVC)
message("Platform assumption: Microsoft Visual C++ (or compatible)")
# Regarding DECLSPEC_[23]D, Clang doesn't want extra []'s for multi-dimensional
# __declspec getters & putters.
target_compile_definitions(OpenDSSC PRIVATE
DECLSPEC_2D=[]
DECLSPEC_3D=[][]
)
target_compile_options(OpenDSSC PRIVATE
#/fsanitize=address
)
else()
message("Platform assumption: Linux or UNIX")
# Regarding DECLSPEC_[23]D, Visual C++ wants extra []'s for multi-dimensional
# __declspec getters & putters.
#
# Define _D2C_SYSFILE_H_LONG_IS_INT64 if long is the same as int64_t for d2c_sysfile.{h,cpp}
# TODO: How may _D2C_SYSFILE_H_LONG_IS_INT64 be checked at compile time? The
# cleanest way would be to rewrite that mess with a few C++ templates.
#
# _COMPLEX_DEFINED is to prevent klusolve.h from defining complex with a
# conflicting set of names.
target_compile_definitions(OpenDSSC PRIVATE
_D2C_SYSFILE_H_LONG_IS_INT64
_COMPLEX_DEFINED
)
endif()
target_include_directories(OpenDSSC PRIVATE
Common
Controls
Executive
Forms
General
GISCommands
Meters
MyOpenDSS
Parser
PCElements
PDElements
Shared
Support
MyOpenDSS
GenModels
GenControls/Exciter
GenControls/Governor
Plot
)
if(MSVC)
# Windows:
target_link_libraries(OpenDSSC
${CMAKE_THREAD_LIBS_INIT}
klusolve_all
)
else()
# Linux:
target_link_libraries(OpenDSSC
${CMAKE_THREAD_LIBS_INIT}
klusolve_all
stdc++fs
dl
uuid
# iconv # iconv seems to be required on more recent compilers
)
endif()
# TODO: Add tests and install targets if needed.
install (TARGETS OpenDSSC DESTINATION "openDSSX/bin")