forked from ElmerCSC/elmerfem
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
315 lines (271 loc) · 10 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
#
# Experimental CMake configuration script for Elmer
#
# Authors:
# Sami Ilvonen, CSC - IT Center for Science, Ltd.
# Phil Weir, NUMA Engineering Services, Ltd.
# Mikko Byckling, CSC - IT Center for Science Ltd.
# Juhani Kataja, CSC - IT Center for Science Ltd.
#
# First public beta release 11th of October, 2013
#
# Note that this version is highly experimental and includes
# only a very limited subset of features that are supported
# by the original autotools scripts.
#
PROJECT(Elmer Fortran C CXX)
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.9)
IF(APPLE)
SET(CMAKE_MACOSX_RPATH 1)
ENDIF()
SET(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake/Modules" ${CMAKE_ROOT}/Modules)
# Defaults to cache variables
SET(WITH_MPI TRUE CACHE BOOL "Use MPI parallelization")
SET(WITH_OpenMP FALSE CACHE BOOL "Use OpenMP thread parallelization")
SET(WITH_Mumps FALSE CACHE BOOL "Use Mumps sparse direct solver")
SET(WITH_Hypre FALSE CACHE BOOL "Use Hypre linear algebra library")
SET(WITH_ELMERGUI FALSE CACHE BOOL "Include ElmerGUI")
SET(WITH_ElmerIce FALSE CACHE BOOL "Include ElmerIce")
SET(WITH_ELMERGUITESTER FALSE CACHE BOOL "Include ElmerGUI tester")
SET(WITH_ELMERGUILOGGER FALSE CACHE BOOL "Include ElmerGUI logger")
SET(ELMER_INSTALL_LIB_DIR "lib/elmersolver" CACHE PATH "Location of elmer shared libraries relative to prefix.")
SET(WITH_Trilinos FALSE CACHE BOOL "Use Trilinos")
SET(WITH_ELMERPOST FALSE CACHE BOOL "Include ElmerPost (DEPRECATED)")
MARK_AS_ADVANCED(WITH_ELMERPOST)
if("${CMAKE_VERSION}" VERSION_GREATER 2.8.12)
CMAKE_POLICY(SET CMP0022 OLD)
ENDIF()
MARK_AS_ADVANCED(ELMER_INSTALL_LIB_DIR)
ENABLE_TESTING()
SET(ELMER_FEM_MAJOR_VERSION 7)
SET(ELMER_FEM_MINOR_VERSION 0)
SET(ELMER_FEM_VERSION
${ELMER_FEM_MAJOR_VERSION}.${ELMER_FEM_MINOR_VERSION})
IF(NOT(ELMER_FEM_REVISION))
execute_process(
COMMAND "git" "--no-pager" "log" "-1" "--pretty=format:%h"
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
OUTPUT_VARIABLE ELMER_FEM_REVISION_
RESULT_VARIABLE RUN_RETURN_VALUE)
IF(RUN_RETURN_VALUE EQUAL 0)
SET(ELMER_FEM_REVISION ${ELMER_FEM_REVISION_} CACHE STRING "" FORCE)
MARK_AS_ADVANCED(ELMER_FEM_REVISION)
ENDIF()
ENDIF()
SET(VERSION ${ELMER_FEM_VERSION})
SET(REVISION ${ELMER_FEM_REVISION})
SET(CMAKE_POSITION_INDEPENDENT_CODE TRUE)
# MESSAGE("Fortran: ${CMAKE_Fortran_COMPILER_LOADED}")
IF(WITH_OpenMP)
# Advanced properties
MARK_AS_ADVANCED(
OpenMP_C_FLAGS
OpenMP_Fortran_FLAGS
OpenMP_CXX_FLAGS
)
FIND_PACKAGE(OpenMP REQUIRED)
# Add OpenMP flags to compilation flags
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
SET(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} ${OpenMP_Fortran_FLAGS}")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
ENDIF()
IF(WITH_MPI)
# Advanced properties
MARK_AS_ADVANCED(
MPI_EXTRA_LIBRARY
MPI_LIBRARY
)
FIND_PACKAGE(MPI REQUIRED)
# Workaround if MPI is found but MPI_FOUND is not set (windows+msmpi+findmpi)
SET(MPI_FOUND TRUE CACHE BOOL "")
MARK_AS_ADVANCED(MPI_FOUND)
INCLUDE_DIRECTORIES(${MPI_Fortran_INCLUDE_PATH})
# MPI libraries may be needed for testing
SET(CMAKE_C_REQUIRED_LIBRARIES ${MPI_C_LIBRARIES})
SET(CMAKE_CXX_REQUIRED_LIBRARIES ${MPI_CXX_LIBRARIES})
SET(CMAKE_Fortran_REQUIRED_LIBRARIES ${MPI_Fortran_LIBRARIES})
ENDIF(WITH_MPI)
# MARK_AS_ADVANCED(WITH_Trilinos)
IF(WITH_Trilinos)
FIND_PACKAGE(ML REQUIRED)
FIND_PACKAGE(Trilinos REQUIRED)
FIND_PACKAGE(Belos REQUIRED)
IF(ML_DIR)
ADD_DEFINITIONS(-DHAVE_TRILINOS)
ENDIF()
ENDIF()
# MPI and LAPACK
FIND_PACKAGE(BLAS REQUIRED)
FIND_PACKAGE(LAPACK REQUIRED)
# BLAS and LAPACK libraries may be needed for testing
SET(CMAKE_REQUIRED_LIBRARIES
${CMAKE_REQUIRED_LIBRARIES} ${BLAS_LIBRARIES} ${LAPACK_LIBRARIES})
IF(MPI_FOUND)
# Mumps
IF(WITH_Mumps)
FIND_PACKAGE(Mumps REQUIRED)
ENDIF()
# Hypre
IF(WITH_Hypre)
FIND_PACKAGE(Hypre COMPONENTS Euclid parcsr_ls ParaSails IJ_mv QUIET)
ENDIF()
ENDIF()
IF(Mumps_FOUND)
SET(HAVE_MUMPS TRUE)
MARK_AS_ADVANCED(HAVE_MUMPS)
INCLUDE_DIRECTORIES(${Mumps_INCLUDE_DIR})
# LINK_DIRECTORIES(${MUMPS_LIBRARIES})
ENDIF()
IF(Hypre_FOUND)
SET(HAVE_HYPRE TRUE)
MARK_AS_ADVANCED(HAVE_HYPRE)
INCLUDE_DIRECTORIES(${Hypre_INCLUDE_DIR})
# LINK_DIRECTORIES(${Hypre_LIBRARIES})
ENDIF()
# Check if Fortran compiler supports contiguous keyword
INCLUDE(testContiguous)
IF(CMAKE_Fortran_COMPILER_SUPPORTS_CONTIGUOUS)
ADD_DEFINITIONS(-DCONTIG=,CONTIGUOUS)
ELSE()
ADD_DEFINITIONS(-DCONTIG=)
ENDIF()
# Check if this is mingw toolchain.
IF(MINGW)
ADD_DEFINITIONS(-DMINGW32)
ENDIF()
IF(WIN32)
ADD_DEFINITIONS(-DWIN32)
ENDIF()
# Check if Fortran compiler supports execute_command_line
INCLUDE(testExecutecommand)
IF(CMAKE_Fortran_COMPILER_SUPPORTS_EXECUTECOMMANDLINE)
ADD_DEFINITIONS(-DHAVE_EXECUTECOMMANDLINE)
ENDIF()
ADD_DEFINITIONS(-DUSE_ISO_C_BINDINGS)
SET(FC_STDCALLBULL " ")
SET(ELMER_LINKTYP 1)
#SET(FC_FUNC FC_GLOBAL)
#SET(FC_FUNC_ FC_GLOBAL_)
# Add support for arpack
ADD_DEFINITIONS(-DUSE_ARPACK)
#INCLUDE(FortranCInterface)
#FortranCInterface_HEADER(FCMangle.h MACRO_NAMESPACE "FC_")
#FortranCInterface_VERIFY(CXX)
# Set up rpaths to point ELMER_INSTALL_LIB_DIR
IF(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
SET(ELMERSOLVER_RPATH_STRING "\$ORIGIN/../${ELMER_INSTALL_LIB_DIR}")
ELSEIF(APPLE)
SET(ELMERSOLVER_RPATH_STRING "@loader_path/../${ELMER_INSTALL_LIB_DIR}")
ENDIF()
# Uncomment these to use rpath with linked libraries
# SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
# SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
# Remove system directories (from the CMake guide)
# LIST(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_PREFIX}/lib" isSystemDir)
# IF("${isSystemDir}" STREQUAL "-1")
# SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
# ENDIF("${isSystemDir}" STREQUAL "-1")
MARK_AS_ADVANCED(USE_EIO)
ADD_SUBDIRECTORY(matc)
IF(WITH_EIO)
ADD_SUBDIRECTORY(eio)
SET(HAVE_EIO TRUE)
MARK_AS_ADVANCED(HAVE_EIO)
ENDIF()
IF(WITH_ElmerIce)
MESSAGE(STATUS "Adding optional package ElmerIce")
ADD_SUBDIRECTORY(elmerice)
ENDIF()
ADD_SUBDIRECTORY(umfpack)
ADD_SUBDIRECTORY(fhutiter)
ADD_SUBDIRECTORY(meshgen2d)
ADD_SUBDIRECTORY(fem)
ADD_SUBDIRECTORY(mathlibs)
ADD_SUBDIRECTORY(elmergrid)
ADD_SUBDIRECTORY(license_texts)
IF(WITH_ELMERGUI)
MESSAGE(STATUS " Building ElmerGUI")
MESSAGE(STATUS "------------------------------------------------")
ADD_SUBDIRECTORY(ElmerGUI)
ENDIF()
IF(WITH_ELMERGUITESTER)
ADD_SUBDIRECTORY(ElmerGUItester)
ENDIF(WITH_ELMERGUITESTER)
IF(WITH_ELMERGUILOGGER)
ADD_SUBDIRECTORY(ElmerGUIlogger)
ENDIF(WITH_ELMERGUILOGGER)
#INCLUDE(FeatureSummary)
#FEATURE_SUMMARY(WHAT ENABLED_FEATURES
# INCLUDE_QUIET_PACKAGES
# DESCRIPTION "Enabled Features:"
# VAR enabledFeaturesText)
#MESSAGE(STATUS "${enabledFeaturesText}")
#
MESSAGE(STATUS "------------------------------------------------")
MESSAGE(STATUS " BLAS library: " "${BLAS_LIBRARIES}")
MESSAGE(STATUS " LAPACK library: " "${LAPACK_LIBRARIES}")
MESSAGE(STATUS "------------------------------------------------")
MESSAGE(STATUS " Fortran compiler: " "${CMAKE_Fortran_COMPILER}")
MESSAGE(STATUS " Fortran flags: " "${CMAKE_Fortran_FLAGS}")
MESSAGE(STATUS "------------------------------------------------")
MESSAGE(STATUS " C compiler: " "${CMAKE_C_COMPILER}")
MESSAGE(STATUS " C flags: " "${CMAKE_C_FLAGS}")
MESSAGE(STATUS "------------------------------------------------")
IF(WITH_MPI)
MESSAGE(STATUS " MPI Fortran: " "${MPI_Fortran_FOUND}")
MESSAGE(STATUS " MPI Fortran compiler: " "${MPI_Fortran_COMPILER}")
MESSAGE(STATUS " MPI Fortran flags: " "${MPI_Fortran_COMPILE_FLAGS}")
MESSAGE(STATUS " MPI Fortran include dir: " "${MPI_Fortran_INCLUDE_PATH}")
MESSAGE(STATUS " MPI Fortran libraries: " "${MPI_Fortran_LIBRARIES}")
MESSAGE(STATUS " MPI Fortran link flags: " "${MPI_Fortran_LINK_FLAGS}")
MESSAGE(STATUS "------------------------------------------------")
MESSAGE(STATUS " MPI C: " "${MPI_C_FOUND}")
MESSAGE(STATUS " MPI C compiler: " "${MPI_C_COMPILER}")
MESSAGE(STATUS " MPI C flags: " "${MPI_C_COMPILE_FLAGS}")
MESSAGE(STATUS " MPI C include dir: " "${MPI_C_INCLUDE_PATH}")
MESSAGE(STATUS " MPI C libraries: " "${MPI_C_LIBRARIES}")
MESSAGE(STATUS " MPI C flags: " "${MPI_C_LINK_FLAGS}")
MESSAGE(STATUS "------------------------------------------------")
IF(WITH_Mumps)
MESSAGE(STATUS " Mumps: " "${Mumps_FOUND}")
MESSAGE(STATUS " Mumps include: " "${Mumps_INCLUDE_DIR}")
MESSAGE(STATUS " Mumps libraries: " "${Mumps_LIBRARIES}")
MESSAGE(STATUS "------------------------------------------------")
ENDIF()
IF(WITH_Hypre)
MESSAGE(STATUS " Hypre: " "${Hypre_FOUND}")
MESSAGE(STATUS " Hypre include: " "${Hypre_INCLUDE_DIR}")
MESSAGE(STATUS " Hypre libraries: " "${Hypre_LIBRARIES}")
MESSAGE(STATUS "------------------------------------------------")
ENDIF()
ELSE()
MESSAGE(STATUS " Fortran compiler: " "${CMAKE_Fortran_COMPILER}")
MESSAGE(STATUS "------------------------------------------------")
MESSAGE(STATUS " C compiler: " "${CMAKE_C_COMPILER}")
MESSAGE(STATUS "------------------------------------------------")
MESSAGE(STATUS " C++ compiler: " "${CMAKE_CXX_COMPILER}")
MESSAGE(STATUS "------------------------------------------------")
ENDIF()
IF(WITH_Trilinos)
MESSAGE(STATUS " Trilinos: " "${Trilinos_FOUND}")
MESSAGE(STATUS " Trilinos_DIR: " "${Trilinos_DIR}")
MESSAGE(STATUS " Trilinos_LIBRARIES: " "${Trilinos_LIBRARIES}")
MESSAGE(STATUS "------------------------------------------------")
ENDIF()
IF(WITH_ELMERGUITESTER)
MESSAGE(STATUS " Building ElmerGUI tester")
MESSAGE(STATUS "------------------------------------------------")
ENDIF()
IF(WITH_ELMERGUILOGGER)
MESSAGE(STATUS " Building ElmerGUI logger")
MESSAGE(STATUS "------------------------------------------------")
ENDIF()
IF(WITH_ELMERPOST)
MESSAGE(WARNING " Building ElmerPost")
MESSAGE(STATUS "------------------------------------------------")
ADD_SUBDIRECTORY(post)
ENDIF()
# Packaging
if(NOT BYPASS_CPACK)
INCLUDE(${CMAKE_CURRENT_SOURCE_DIR}/cpack/ElmerCPack.cmake)
endif()