-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathCMakeLists.txt
261 lines (223 loc) · 8.2 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
# set minimal version the one requested by kokkos
cmake_minimum_required(VERSION 3.18)
# The ``target_sources()`` command converts relative paths to absolute.
if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.13.0")
message(STATUS "Setting policy CMP0076 to use new behavior")
cmake_policy(SET CMP0076 NEW)
endif()
# CMake 3.24 and above prefers to set the timestamps of all extracted contents
# to the time of the extraction.
if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.24)
cmake_policy(SET CMP0135 NEW)
endif()
#
# default local cmake macro repository
#
list(INSERT CMAKE_MODULE_PATH 0 "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
#
# Prevent from build in source tree
#
include(preventBuildInSource)
#
# Create project version (using git info ?) TODO
#
#
# Init build type: Release, Debug, ...
#
include(initBuildType)
# options
option(EULER_KOKKOS_BUILD_DOC
"Enable / disable documentation build (sphinx/html)" OFF)
option(EULER_KOKKOS_USE_SPHINX_EXHALE
"Enable / disable building API documentation (very long)" OFF)
option(EULER_KOKKOS_USE_MPI "Activate / want MPI build" OFF)
option(EULER_KOKKOS_USE_VTK "Activate / want VTK build" OFF)
option(EULER_KOKKOS_USE_DOUBLE "build with double precision" ON)
option(EULER_KOKKOS_USE_HDF5 "build HDF5 input/output support" OFF)
option(EULER_KOKKOS_USE_PNETCDF
"build PNETCDF input/output support (MPI required)" OFF)
option(EULER_KOKKOS_USE_FPE_DEBUG
"build with floating point Nan tracing (signal handler)" OFF)
option(
EULER_KOKKOS_USE_MPI_CUDA_AWARE_ENFORCED
"Some MPI cuda-aware implementation are not well detected; use this to enforce"
OFF)
# disable base languages
unset(PROJECT_LANGUAGES)
set(PROJECT_LANGUAGES ${PROJECT_LANGUAGES} C CXX)
set(EULER_KOKKOS_VERSION "0.9.0")
# deduce EULER_KOKKOS_SHORT_VERSION using regex
string(REGEX MATCH "^[0-9]+\.[0-9]+\.[0-9]+" EULER_KOKKOS_SHORT_VERSION
${EULER_KOKKOS_VERSION})
if("${EULER_KOKKOS_SHORT_VERSION}" STREQUAL "")
message(
FATAL_ERROR
"Unable to compute short version from EULER_KOKKOS_VERSION=${EULER_KOKKOS_VERSION}"
)
endif()
project(
euler_kokkos
VERSION ${EULER_KOKKOS_SHORT_VERSION}
LANGUAGES ${PROJECT_LANGUAGES})
# Documentation type
if(EULER_KOKKOS_BUILD_DOC)
set(EULER_KOKKOS_DOC_TYPE
"Undefined"
CACHE
STRING
"The documentation type to generate. Available values are html and doxygen"
)
# Set the possible values for documentation type
set_property(CACHE EULER_KOKKOS_DOC_TYPE PROPERTY STRINGS "html" "doxygen"
"Undefined")
add_subdirectory(doc)
return()
endif()
# always export compile commands database
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
# C++17 is for Kokkos
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_EXTENSIONS OFF)
# ##############################################################################
#
# check MPI, VTK, HDF5, PNETCDF, ...
#
# ##############################################################################
include(cmake/config_mpi.cmake)
if(EULER_KOKKOS_USE_VTK)
# look for VTK only if requested; VTK macro might even be not present on the
# target platform
find_package(
VTK
COMPONENTS CommonCore
CommonDataModel
CommonExecutionModel
CommonMath
CommonMisc
CommonSystem
CommonTransforms
IOCore
IOGeometry
IOImage
IOLegacy
IOXML
IOXMLParser
ParallelCore
ParallelMPI
IOParallelXML)
if(VTK_FOUND)
message("VTK version: ${VTK_VERSION}")
else()
message("VTK NOT FOUND")
endif()
endif(EULER_KOKKOS_USE_VTK)
# ##############################################################################
# HDF5
# ##############################################################################
include(cmake/config_hdf5.cmake)
# ##############################################################################
# PNETCDF
# ##############################################################################
if(EULER_KOKKOS_USE_MPI)
if(EULER_KOKKOS_USE_PNETCDF)
find_package(PNETCDF)
if(PNETCDF_FOUND)
add_compile_options(-DUSE_PNETCDF)
include_directories(${PNETCDF_INCLUDE_DIRS})
endif(PNETCDF_FOUND)
endif(EULER_KOKKOS_USE_PNETCDF)
endif(EULER_KOKKOS_USE_MPI)
#
# Kokkos : https://github.com/kokkos/kokkos
#
include(build_or_find_kokkos)
#
# Using flags -Wextra, it's to strong for Kokkos, too many warnings But -Wall is
# really a minimum
#
# add_definitions(-Wall -Wextra -Wconversion -Wshadow -Wnon-virtual-dtor
# -Wold-style-cast -Wcast-align -Wcast-qual -Wunused -Woverloaded-virtual
# -pedantic ) add_definitions( -Wall -Wextra )
add_definitions(-Wall)
# Generate euler_kokkos_config.h and euler_kokkos_version.h (with git info and
# build date)
#
include(cmake/generate_config_h.cmake)
#
# sources
#
add_subdirectory(test)
add_subdirectory(src)
# #################### PRINT CONFIGURE STATUS ######################
message("//===================================================")
message("// ${PROJECT_NAME} build configuration:")
message("//===================================================")
message("")
message(" CMake version : ${CMAKE_VERSION}")
if(NOT CMAKE_BUILD_TYPE)
message(" CMake build type : NOT SET !")
else()
message(" CMake build type : ${CMAKE_BUILD_TYPE}")
endif()
message(" CMake install prefix : ${CMAKE_INSTALL_PREFIX}")
message(" CMake system processor : ${CMAKE_SYSTEM_PROCESSOR}")
message(" CMake system name (OS) : ${CMAKE_SYSTEM_NAME}")
message("")
message(" C++ Compiler : ${CMAKE_CXX_COMPILER_ID} "
"${CMAKE_CXX_COMPILER_VERSION} " "${CMAKE_CXX_COMPILER_WRAPPER}")
message(" ${CMAKE_CXX_COMPILER}")
message(" MPI enabled = ${EULER_KOKKOS_USE_MPI}")
message(" Kokkos version = ${Kokkos_VERSION}")
message(" Kokkos_CXX_COMPILER = ${Kokkos_CXX_COMPILER}")
message(" Kokkos_CXX_COMPILER_ID = ${Kokkos_CXX_COMPILER_ID}")
message(" Kokkos_CXX_STANDARD = ${Kokkos_CXX_STANDARD}")
message(" Kokkos_OPTIONS = ${Kokkos_OPTIONS}")
message(" Kokkos_TPLS = ${Kokkos_TPLS}")
message(" Kokkos_DIRS = ${Kokkos_DIR}")
if(Kokkos_ENABLE_OPENMP)
message(" Kokkos_ENABLE_OPENMP = ${Kokkos_ENABLE_OPENMP}")
endif()
if(Kokkos_ENABLE_CUDA)
message(" Kokkos_ENABLE_CUDA = ${Kokkos_ENABLE_CUDA}")
if((${Kokkos_CUDA_LAMBDA_ENABLED}) OR (${Kokkos_ENABLE_CUDA_LAMBDA}))
message(" Kokkos_ENABLE_CUDA_LAMBDA = ON")
else()
message(" Kokkos_ENABLE_CUDA_LAMBDA = OFF")
endif()
if((${Kokkos_CUDA_CONSTEXPR_ENABLED}) OR (${Kokkos_ENABLE_CUDA_CONSTEXPR}))
message(" Kokkos_ENABLE_CUDA_CONSTEXPR = ON")
else()
message(" Kokkos_ENABLE_CUDA_CONSTEXPR = OFF")
endif()
if((${Kokkos_CUDA_UVM_ENABLED}) OR (${Kokkos_ENABLE_CUDA_UVM}))
message(" Kokkos_ENABLE_CUDA_UVM = ON")
else()
message(" Kokkos_ENABLE_CUDA_UVM = OFF")
endif()
message(" Kokkos CUDA flags = ${KOKKOS_CUDA_OPTIONS}")
# message(" CUDA Compiler : ${CMAKE_CUDA_COMPILER}") message(" CUDA
# Compiler exec : ${CUDA_NVCC_EXECUTABLE}") message(" CUDA Compile flags :
# ${CUDA_NVCC_FLAGS}")
endif(Kokkos_ENABLE_CUDA)
if(Kokkos_ENABLE_HIP)
message(" Kokkos_ENABLE_HIP = ${Kokkos_ENABLE_HIP}")
endif(Kokkos_ENABLE_HIP)
if((${Kokkos_TPLS_HWLOC_ENABLED}) OR (${Kokkos_ENABLE_HWLOC}))
message(" Kokkos_ENABLE_HWLOC = ON")
else()
message(" Kokkos_ENABLE_HWLOC = OFF")
endif()
message(" Kokkos architecture = ${Kokkos_ARCH}")
if(HDF5_FOUND)
message(" HDF5_VERSION = ${HDF5_VERSION}")
message(" HDF5_DEFINITIONS = ${HDF5_DEFINITIONS}")
message(" HDF5_IS_PARALLEL = ${HDF5_IS_PARALLEL}")
message(" HDF5_INCLUDE_DIRS = ${HDF5_INCLUDE_DIRS}")
message(" HDF5_LIBRARIES = ${HDF5_LIBRARIES}")
endif(HDF5_FOUND)
if(PNETCDF_FOUND)
message(" PNETCDF_VERSION_STRING = ${PNETCDF_VERSION_STRING}")
message(" PNETCDF_INCLUDE_DIRS = ${PNETCDF_INCLUDE_DIRS}")
message(" PNETCDF_LIBRARIES = ${PNETCDF_LIBRARIES}")
endif(PNETCDF_FOUND)
message("")