-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCMakeLists.txt
371 lines (309 loc) · 11.1 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
cmake_minimum_required(VERSION 3.1)
# Set project metadata #########################################################
project(RocFOAM CXX)
set(RocFOAM_MAJOR_VERSION 1)
set(RocFOAM_MINOR_VERSION 0)
set(RocFOAM_PATCH_VERSION 5)
set(RocFOAM_EXTRA_VERSION "")
set(RocFOAM_VERSION "${RocFOAM_MAJOR_VERSION}.${RocFOAM_MINOR_VERSION}")
set(RocFOAM_VERSION "${RocFOAM_VERSION}.${RocFOAM_PATCH_VERSION}${RocFOAM_EXTRA_VERSION}")
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_EXTENSIONS OFF)
# Set project defaults #########################################################
# package module
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/cmake/Modules/)
# Set a default build type if none was specified
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
message(STATUS "Setting build type to 'Release' as none was specified.")
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build." FORCE)
endif()
# Set the possible values of build type for cmake-gui
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release"
"MinSizeRel" "RelWithDebInfo")
# creating code compilation database
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
# Installation Directories
include(GNUInstallDirs)
# Setting configure options ####################################################
option(ENABLE_TESTING "Enable Testing of RocFOAM." ON)
option(ENABLE_VERBOSITY "Enable Verbosity of RocFOAM." OFF)
# Setting compile and link options #############################################
# Turn on default warnings for GNU compilers.
if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
# Update if necessary
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wpedantic")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wextra -Wno-unused-parameter")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-invalid-offsetof -Wno-attributes")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wold-style-cast -Wnon-virtual-dtor")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wstrict-null-sentinel -Wredundant-decls")
# -Wshadow gives false positives for gcc versions <= 4.8
if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 4.9)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wshadow")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wfloat-conversion")
endif(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 4.9)
endif()
# set up RPATH
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_FULL_LIBDIR}")
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
# Finding libraries ############################################################
# Find OpenFOAM
# checking OpenFOAM version
string(FIND $ENV{WM_PROJECT_VERSION} "2006" OF20)
if(OF20 GREATER -1)
set(OF_VERSION 20)
endif()
string(FIND $ENV{WM_PROJECT_VERSION} "7" OF7)
if(OF7 GREATER -1)
set(OF_VERSION 7)
endif()
string(FIND $ENV{WM_PROJECT_VERSION} "8" OF8)
if(OF8 GREATER -1)
set(OF_VERSION 8)
endif()
message(STATUS "OpenFOAM version ${OF_VERSION}")
if(OF_VERSION EQUAL 20)
find_package(OpenFOAM REQUIRED COMPONENTS OpenFOAM finiteVolume fvOptions
compressibleTransportModels
fluidThermophysicalModels specie
turbulenceModels compressibleTurbulenceModels
dynamicFvMesh
topoChangerFvMesh meshTools Pstream)
elseif(OF_VERSION EQUAL 7)
find_package(OpenFOAM REQUIRED COMPONENTS OpenFOAM finiteVolume fvOptions
compressibleTransportModels
fluidThermophysicalModels specie
turbulenceModels compressibleTurbulenceModels
dynamicFvMesh
topoChangerFvMesh meshTools Pstream)
elseif(OF_VERSION EQUAL 8)
find_package(OpenFOAM REQUIRED COMPONENTS OpenFOAM finiteVolume fvOptions
momentumTransportModels fluidThermoMomentumTransportModels
thermophysicalTransportModels
fluidThermophysicalModels specie
dynamicFvMesh sampling
topoChangerFvMesh meshTools Pstream)
else()
message(STATUS "OpenFOAM version not identified/supported")
# # > 7.x series
# find_package(OpenFOAM REQUIRED COMPONENTS OpenFOAM finiteVolume fvOptions
# compressibleTransportModels
# compressibleTurbulenceModels
# fluidThermophysicalModels specie
# turbulenceModels dynamicFvMesh
# topoChangerFvMesh meshTools Pstream)
endif()
message(STATUS "OpenFOAM include directory ${OPNF_INCLUDE_DIRS}")
message(STATUS "OpenFOAM link directory ${OPNF_LIBRARY_DIRS}")
# Find IMPACT
find_package(IMPACT REQUIRED)
# Find Boost
#set(Boost_USE_MULTITHREADED ON)
find_package(Boost 1.45.0 REQUIRED COMPONENTS filesystem)
# Setting library files ########################################################
# Setting include files
file(GLOB_RECURSE RocFOAM_INC_FILES *.H)
set(RocFOAM_INC_DIRS "")
foreach(file_path ${RocFOAM_INC_FILES})
get_filename_component(dir_path ${file_path} PATH)
list(APPEND RocFOAM_INC_DIRS ${dir_path})
endforeach()
list(REMOVE_DUPLICATES RocFOAM_INC_DIRS)
# Setting RocFOAM source
set(RocFOAM_SRCS
src/foam/rocFoam.C
src/foam/comFoam.C
src/foam/fileContainer.C
src/BCs/rocstarFSI.C
src/BCs/rocstarFSISolidBodyMotion.C
src/foam/statusMethods.C
src/foam/volumeMethods.C
src/foam/faceMethods.C
src/foam/surfaceMethods.C
src/foam/reconstMethods.C
src/foam/filesMethods.C
src/foam/zonesMethods.C
)
set(rocrhopimple_SRCS
${RocFOAM_SRCS}
src/rhoPimple/rocRhoPimple.C)
# Setting rhoPimple driver source
set(rocPmpDrv_SRCS src/rhoPimple/rocRhoPimple_drv.C)
# Setting rocrhocentral source
set(rocrhocentral_SRCS
${RocFOAM_SRCS}
src/rhoCentral/rocRhoCentral.C)
# Setting rhoCentral driver source
set(rocCntDrv_SRCS src/rhoCentral/rocRhoCentral_drv.C)
# Setting rhoFoam driver source
set(rocFoamDrv_SRCS src/foam/rocFoam_drv.C)
# Building library #############################################################
# Build rocrhopimple library ^^^^^^^^^^^^^^^^^^^^^^^^
add_library(rocrhopimple ${rocrhopimple_SRCS})
target_include_directories(rocrhopimple
PUBLIC
Boost::headers
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/rocfoam>
)
foreach(include_dir ${RocFOAM_INC_DIRS})
target_include_directories(rocrhopimple
PUBLIC
$<BUILD_INTERFACE:${include_dir}>
)
endforeach()
target_compile_options(rocrhopimple
PUBLIC
-Wall
-Wextra
-Wold-style-cast
-Wnon-virtual-dtor
-Wno-unused-parameter
-Wno-invalid-offsetof
PUBLIC
-ftemplate-depth-100
)
# Link OpenFOAM
target_link_libraries(rocrhopimple
PUBLIC
${OPNF_LIBRARIES}
Boost::filesystem
IMPACT::SITCOM
)
target_include_directories(rocrhopimple SYSTEM
PUBLIC
${OPNF_INCLUDE_DIRS}
)
target_compile_definitions(rocrhopimple
PUBLIC
${OPNF_COMPILE_DEFINITIONS}
)
if(ENABLE_VERBOSITY)
target_compile_definitions(rocrhopimple PUBLIC VERBOSE)
endif()
if(OF_VERSION EQUAL 20)
target_compile_definitions(rocrhopimple PUBLIC HAVE_OFE20)
elseif(OF_VERSION EQUAL 7)
target_compile_definitions(rocrhopimple PUBLIC HAVE_OF7)
elseif(OF_VERSION EQUAL 8)
target_compile_definitions(rocrhopimple PUBLIC HAVE_OF8)
endif()
message(STATUS "OPENFOAM VERSION ${OF_VERSION}")
#----------------------------------------------------
# Build rocRhoCentral library ^^^^^^^^^^^^^^^^^^^^^^^
add_library(rocrhocentral ${rocrhocentral_SRCS})
target_include_directories(rocrhocentral
PUBLIC
Boost::headers
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/rocfoam>
)
foreach(include_dir ${RocFOAM_INC_DIRS})
target_include_directories(rocrhocentral
PUBLIC
$<BUILD_INTERFACE:${include_dir}>
)
endforeach()
target_compile_options(rocrhocentral
PUBLIC
-Wall
-Wextra
-Wold-style-cast
-Wnon-virtual-dtor
-Wno-unused-parameter
-Wno-invalid-offsetof
PUBLIC
-ftemplate-depth-100
)
# Link OpenFOAM
target_link_libraries(rocrhocentral
PUBLIC
${OPNF_LIBRARIES}
Boost::filesystem
IMPACT::SITCOM
)
target_include_directories(rocrhocentral SYSTEM
PUBLIC
${OPNF_INCLUDE_DIRS}
)
target_compile_definitions(rocrhocentral
PUBLIC
${OPNF_COMPILE_DEFINITIONS}
)
if(ENABLE_VERBOSITY)
target_compile_definitions(rocrhocentral PUBLIC VERBOSE)
endif()
if(OF_VERSION EQUAL 20)
target_compile_definitions(rocrhocentral PUBLIC HAVE_OFE20)
elseif(OF_VERSION EQUAL 7)
target_compile_definitions(rocrhocentral PUBLIC HAVE_OF7)
elseif(OF_VERSION EQUAL 8)
target_compile_definitions(rocrhocentral PUBLIC HAVE_OF8)
endif()
message(STATUS "OPENFOAM VERSION ${OF_VERSION}")
#----------------------------------------------------
# Set soname version ###########################################################
# Set soname version
message(STATUS "RocFOAM_VERSION: ${RocFOAM_VERSION}")
message(STATUS "RocFOAM_MAJOR_VERSION: ${RocFOAM_MAJOR_VERSION}")
set_target_properties(rocrhopimple PROPERTIES VERSION ${RocFOAM_VERSION}
SOVERSION ${RocFOAM_MAJOR_VERSION})
# Set soname version
set_target_properties(rocrhocentral PROPERTIES VERSION ${RocFOAM_VERSION}
SOVERSION ${RocFOAM_MAJOR_VERSION})
# Install libraries ############################################################
# rocrhopimple ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
# Headers
install(FILES ${RocFOAM_INC_FILES}
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
# Libraries
install(TARGETS rocrhopimple
EXPORT rocrhopimple
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE
GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
#------------------------------------------------
# rocrhocentral ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
# Headers
install(FILES ${RocFOAM_INC_FILES}
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
# Libraries
install(TARGETS rocrhocentral
EXPORT rocrhocentral
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE
GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
#------------------------------------------------
# Building utilities ###########################################################
add_executable(rocRhoCentral ${rocCntDrv_SRCS})
target_link_libraries(rocRhoCentral rocrhocentral IMPACT::SITCOM)
target_include_directories(rocRhoCentral SYSTEM
PUBLIC
${OPNF_INCLUDE_DIRS}
)
add_executable(rocRhoPimple ${rocPmpDrv_SRCS})
target_link_libraries(rocRhoPimple rocrhopimple IMPACT::SITCOM)
target_include_directories(rocRhoPimple SYSTEM
PRIVATE
${OPNF_INCLUDE_DIRS}
)
##add_executable(rocFoam ${rocFoamDrv_SRCS})
##target_link_libraries(rocFoam rocfoam IMPACT::SITCOM)
##target_include_directories(rocFoam SYSTEM
## PRIVATE
## ${OPNF_INCLUDE_DIRS}
##)
install(TARGETS rocRhoCentral rocRhoPimple
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE
GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
)
# Perform Testing ##############################################################
if(ENABLE_TESTING)
enable_testing()
add_subdirectory(testing)
endif()