-
Notifications
You must be signed in to change notification settings - Fork 47
/
CMakeLists.txt
executable file
·185 lines (157 loc) · 6.35 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
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.5)
#SET(CMAKE_FORTRAN_COMPILER gfortran gfortran)
PROJECT(PHASTA Fortran C CXX )
enable_language(Fortran)
enable_language(C)
enable_language(CXX)
#The following commit fixes an issue with imported targets and gfortran
#https://gitlab.kitware.com/cmake/cmake/commit/a8e7a1047ad3b61238f073ea3d2cd138f207c1ed
if(${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} VERSION_LESS 3.3.0)
#if the cmake version is too old then set the magic flag to use -I instead of
# -isystem for imported targets - we are importing a fortran module from
# SCOREC/core for phasta io timers
unset(CMAKE_INCLUDE_SYSTEM_FLAG_Fortran)
endif()
enable_testing()
include(CTest)
set(MPIRUN "mpirun"
CACHE STRING
"the mpirun or srun executable")
set(MPIRUN_PROCFLAG "-np"
CACHE STRING
"the command line flag to give process count to MPIRUN")
list(APPEND CMAKE_MODULE_PATH ${PHASTA_SOURCE_DIR}/CMakeFiles)
#Handle Fortran name mangling
include(FortranCInterface)
FortranCInterface_VERIFY(CXX)
FortranCInterface_Header(FCMangle.h SYMBOLS write_restart write_error write_displ write_field write_hessian)
include_directories("${PHASTA_BINARY_DIR}")
# Force static linking
IF(CMAKE_SYSTEM_NAME MATCHES BlueGeneQ-static)
SET(CMAKE_FIND_LIBRARY_SUFFIXES ".a")
ENDIF(CMAKE_SYSTEM_NAME MATCHES BlueGeneQ-static)
#MESSAGE(ERROR ${CMAKE_Fortran_SOURCE_FILE_EXTENSIONS})
#SET(CMAKE_Fortran_SOURCE_FILE_EXTENSIONS f90 f F90 F)
# stuff for C/C++ calls to Fortran -- still needs to be done properly...
IF(CMAKE_Fortran_COMPILER_ID MATCHES GNU)
SET(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -ffixed-form -ffixed-line-length-132 -cpp " )
IF(CMAKE_Fortran_COMPILER_VERSION VERSION_GREATER 9.5.0)
#This feature was introduced in gfortran 10
#the last public release prior was 9.5 and
#version_greater_equal was introduced recently so we implement
#for compatibility.
SET(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fallow-argument-mismatch")
ENDIF(CMAKE_Fortran_COMPILER_VERSION VERSION_GREATER 9.5.0)
ENDIF(CMAKE_Fortran_COMPILER_ID MATCHES GNU)
IF(CMAKE_Fortran_COMPILER_ID MATCHES Intel)
SET(CMAKE_Fortran_FLAGS "-W0 -132 -fixed -fpp ${CMAKE_Fortran_FLAGS}" )
if((CMAKE_BUILD_TYPE MATCHES "Release") OR
(CMAKE_BUILD_TYPE MATCHES "RelWithDebInfo"))
set(CMAKE_Fortran_FLAGS "-O3 -ip ${CMAKE_Fortran_FLAGS}" )
endif()
message(STATUS "Found ifort")
message(STATUS ${CMAKE_Fortran_FLAGS})
ENDIF(CMAKE_Fortran_COMPILER_ID MATCHES Intel)
if(CMAKE_Fortran_COMPILER_ID MATCHES PGI)
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -Mextend")
endif(CMAKE_Fortran_COMPILER_ID MATCHES PGI)
if(CMAKE_Fortran_COMPILER_ID MATCHES XL)
#set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -qstrict -qnullterm -qfixed=132")
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -qnullterm -qfixed=132")
endif(CMAKE_Fortran_COMPILER_ID MATCHES XL)
IF(${CMAKE_BUILD_TYPE} MATCHES "Debug" )
ADD_DEFINITIONS( -DDEBUG )
ENDIF(${CMAKE_BUILD_TYPE} MATCHES "Debug" )
# set archos "like" options for things like c calling fortran bindings
# later on we may want to do it dependent on behavior (e.g.
# C_FORTRAN_CALL == uppercase, underline, nochange)
#OPTION(ARCHOS_OPTION "ArchOS dependent defines (e.g. -DLINUX)" )
SET(ARCHOS_OPTION "-DLINUX" CACHE STRING "ArchOS dependent defines (e.g. -DLINUX)" )
ADD_DEFINITIONS( ${ARCHOS_OPTION} )
SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY
${PHASTA_BINARY_DIR}/lib)
SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY
${PHASTA_BINARY_DIR}/bin)
OPTION(PHASTA_USE_MPI "Build MPI components" ON)
IF(PHASTA_USE_MPI)
ADD_DEFINITIONS( -DPARALLEL -DMPICH_SKIP_MPICXX -DOMPI_SKIP_MPICXX )
option(PHASTA_SKIP_MPI_CHECK "Bypass CMake MPI code. Don't use this" OFF)
mark_as_advanced(FORCE PHASTA_SKIP_MPI_CHECK)
if(NOT PHASTA_SKIP_MPI_CHECK)
FIND_PACKAGE(MPI REQUIRED)
endif()
# SET(CMAKE_MODULE_PATH ${PHASTA_SOURCE_DIR}/CMakeFiles)
# bug in FIND_PACKAGE for Threads -- ignore for now (bug has been reported)...
FIND_PACKAGE(Threads)
IF(Threads_FOUND)
INCLUDE(FindThreads)
ENDIF(Threads_FOUND)
ENDIF(PHASTA_USE_MPI)
if(PHASTA_CHEF_ENABLED)
message(STATUS "PHASTA_CHEF_ENABLED SCOREC_PREFIX ${SCOREC_PREFIX}")
find_package(SCOREC 2.1.0 REQUIRED CONFIG
PATHS ${SCOREC_PREFIX} NO_DEFAULT_PATH)
endif(PHASTA_CHEF_ENABLED)
OPTION(PHASTA_BUILD_PHASTAIO "Build PhastaIO" ON)
if(PHASTA_BUILD_PHASTAIO)
add_subdirectory(phastaIO)
list(APPEND PHASTA_INCLUDES "${PHASTA_SOURCE_DIR}/phastaIO")
if(NOT PHASTA_CHEF_ENABLED)
list(APPEND PHASTA_INCLUDES
"${PHASTA_SOURCE_DIR}/phastaIO/phiotimer_empty")
endif(NOT PHASTA_CHEF_ENABLED)
endif(PHASTA_BUILD_PHASTAIO)
OPTION(PHASTA_BUILD_SHAPEFUNCTION "Build shapeFunction" ON)
if(PHASTA_BUILD_SHAPEFUNCTION)
list(APPEND PHASTA_INCLUDES "${PHASTA_SOURCE_DIR}/shapeFunction/src")
add_subdirectory(shapeFunction)
endif(PHASTA_BUILD_SHAPEFUNCTION)
if(EXISTS ${PHASTA_SOURCE_DIR}/phShape)
OPTION(PHASTA_BUILD_PHSHAPE "Build phShape" OFF)
if(PHASTA_BUILD_PHSHAPE)
list(APPEND PHASTA_INCLUDES "${PHASTA_SOURCE_DIR}/phShape/src")
add_subdirectory(phShape)
endif(PHASTA_BUILD_PHSHAPE)
endif(EXISTS ${PHASTA_SOURCE_DIR}/phShape)
OPTION(PHASTA_USE_SVLS "Build svLS Linear Solver" OFF)
if(PHASTA_USE_SVLS)
message(WARNING "\
svLS has a non-commercial license. \n \
by activating PHASTA_USE_SVLS in cmake \n \
you agree to the terms outlined in \
svLS/license.txt"
)
list(APPEND PHASTA_INCLUDES "${PHASTA_SOURCE_DIR}/svLS")
add_subdirectory(svLS)
endif(PHASTA_USE_SVLS)
OPTION(PHASTA_BUILD_SOLVERS "Build Solvers" ON)
if(PHASTA_BUILD_SOLVERS)
set(PHASTA_BUILD_PHASTAIO ON)
if(PHASTA_USE_MPI)
set(PHASTA_BUILD_METIS ON)
endif(PHASTA_USE_MPI)
list(APPEND PHASTA_INCLUDES "${PHASTA_SOURCE_DIR}/phSolver/common")
include_directories(${PHASTA_INCLUDES})
add_subdirectory(phSolver)
add_subdirectory(checkphasta)
#TODO
endif(PHASTA_BUILD_SOLVERS)
OPTION(PHASTA_BUILD_CONVERTERIO "Build IO converter" ON)
if(PHASTA_BUILD_CONVERTERIO)
add_subdirectory(converterIO)
endif(PHASTA_BUILD_CONVERTERIO)
OPTION(PHASTA_BUILD_ACUSTAT "Build AcuStat" ON)
if(PHASTA_BUILD_ACUSTAT)
add_subdirectory(AcuStat)
endif(PHASTA_BUILD_ACUSTAT)
OPTION(PHASTA_BUILD_M2N "Build M2N" ON)
if(PHASTA_BUILD_M2N)
add_subdirectory(M2N)
endif(PHASTA_BUILD_M2N)
OPTION(PHASTA_BUILD_M2NFixBnd "Build M2NFixBnd" ON)
if(PHASTA_BUILD_M2NFixBnd)
add_subdirectory(M2NFixBnd)
endif(PHASTA_BUILD_M2NFixBnd)
if(EXISTS ${PHASTA_SOURCE_DIR}/phNSpre)
add_subdirectory(phNSpre)
endif(EXISTS ${PHASTA_SOURCE_DIR}/phNSpre)