1
1
# set minimal version the one requested by kokkos
2
2
cmake_minimum_required (VERSION 3.18 )
3
3
4
+ # The ``target_sources()`` command converts relative paths to absolute.
5
+ if (${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.13.0" )
6
+ message (STATUS "Setting policy CMP0076 to use new behavior" )
7
+ cmake_policy (SET CMP0076 NEW )
8
+ endif ()
9
+
10
+ # CMake 3.24 and above prefers to set the timestamps of all extracted contents
11
+ # to the time of the extraction.
12
+ if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.24 )
13
+ cmake_policy (SET CMP0135 NEW )
14
+ endif ()
15
+
4
16
#
5
17
# default local cmake macro repository
6
18
#
@@ -43,7 +55,22 @@ unset(PROJECT_LANGUAGES)
43
55
44
56
set (PROJECT_LANGUAGES ${PROJECT_LANGUAGES} C CXX )
45
57
46
- project (euler_kokkos LANGUAGES ${PROJECT_LANGUAGES} )
58
+ set (EULER_KOKKOS_VERSION "0.9.0" )
59
+
60
+ # deduce EULER_KOKKOS_SHORT_VERSION using regex
61
+ string (REGEX MATCH "^[0-9]+\. [0-9]+\. [0-9]+" EULER_KOKKOS_SHORT_VERSION
62
+ ${EULER_KOKKOS_VERSION} )
63
+ if ("${EULER_KOKKOS_SHORT_VERSION} " STREQUAL "" )
64
+ message (
65
+ FATAL_ERROR
66
+ "Unable to compute short version from EULER_KOKKOS_VERSION=${EULER_KOKKOS_VERSION} "
67
+ )
68
+ endif ()
69
+
70
+ project (
71
+ euler_kokkos
72
+ VERSION ${EULER_KOKKOS_SHORT_VERSION}
73
+ LANGUAGES ${PROJECT_LANGUAGES} )
47
74
48
75
# Documentation type
49
76
if (EULER_KOKKOS_BUILD_DOC )
@@ -67,55 +94,12 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
67
94
set (CMAKE_CXX_STANDARD 17 )
68
95
set (CMAKE_CXX_EXTENSIONS OFF )
69
96
97
+ # ##############################################################################
70
98
#
71
- # Write a small header with build data, git version, etc ...
99
+ # check MPI, VTK, HDF5, PNETCDF, ...
72
100
#
73
- include (write_version )
74
-
75
- # ##############################################################################
76
- # External packages: MPI, ...
77
101
# ##############################################################################
78
-
79
- # ##############################################################################
80
- # find_package(MPI REQUIRED)
81
- find_package (MPI )
82
- if (EULER_KOKKOS_USE_MPI )
83
- if (MPI_CXX_FOUND )
84
- message (STATUS "MPI support found" )
85
- message (STATUS "MPI compile flags: " ${MPI_CXX_COMPILE_FLAGS} )
86
- message (STATUS "MPI include path: " ${MPI_CXX_INCLUDE_PATH} )
87
- message (STATUS "MPI LINK flags path: " ${MPI_CXX_LINK_FLAGS} )
88
- message (STATUS "MPI libraries: " ${MPI_CXX_LIBRARIES} )
89
-
90
- # set(CMAKE_EXE_LINKER_FLAGS ${MPI_CXX_LINK_FLAGS})
91
- find_program (
92
- OMPI_INFO
93
- NAMES ompi_info
94
- HINTS ${MPI_CXX_LIBRARIES} /../bin )
95
-
96
- # Full command line to probe if cuda support in MPI implementation is
97
- # enabled ompi_info --parsable --all | grep
98
- # mpi_built_with_cuda_support:value
99
- if (OMPI_INFO )
100
- execute_process (COMMAND ${OMPI_INFO} OUTPUT_VARIABLE _output )
101
- if ((_output MATCHES "smcuda" ) OR (EULER_KOKKOS_USE_MPI_CUDA_AWARE_ENFORCED
102
- ))
103
- set (MPI_CUDA_AWARE_ENABLED True )
104
- message (STATUS "Found OpenMPI with CUDA support built." )
105
- else ()
106
- set (MPI_CUDA_AWARE_ENABLED False )
107
- message (WARNING "OpenMPI found, but it is not built with CUDA support." )
108
- add_compile_options (-DMPI_CUDA_AWARE_OFF )
109
- endif ()
110
- endif ()
111
- else ()
112
- message (
113
- WARNING
114
- "Not compiling with MPI. Suppress this warning with -DEULER_KOKKOS_USE_MPI=OFF"
115
- )
116
- set (EULER_KOKKOS_USE_MPI OFF )
117
- endif ()
118
- endif ()
102
+ include (cmake/config_mpi.cmake )
119
103
120
104
if (EULER_KOKKOS_USE_VTK )
121
105
# look for VTK only if requested; VTK macro might even be not present on the
@@ -149,22 +133,7 @@ endif(EULER_KOKKOS_USE_VTK)
149
133
# ##############################################################################
150
134
# HDF5
151
135
# ##############################################################################
152
- # prefer using parallel HDF5 when build with mpi
153
- if (EULER_KOKKOS_USE_MPI )
154
- set (HDF5_PREFER_PARALLEL TRUE )
155
- endif (EULER_KOKKOS_USE_MPI )
156
-
157
- if (EULER_KOKKOS_USE_HDF5 )
158
- find_package (HDF5 )
159
- if (HDF5_FOUND )
160
- include_directories (${HDF5_INCLUDE_DIRS} )
161
- set (MY_HDF5_LIBS hdf5 hdf5_cpp )
162
- add_compile_options (-DUSE_HDF5 )
163
- if (HDF5_IS_PARALLEL )
164
- add_compile_options (-DUSE_HDF5_PARALLEL )
165
- endif ()
166
- endif (HDF5_FOUND )
167
- endif (EULER_KOKKOS_USE_HDF5 )
136
+ include (cmake/config_hdf5.cmake )
168
137
169
138
# ##############################################################################
170
139
# PNETCDF
@@ -184,38 +153,6 @@ endif(EULER_KOKKOS_USE_MPI)
184
153
#
185
154
include (build_or_find_kokkos )
186
155
187
- #
188
- # if MPI is enabled and kokkos backend is cuda, we need a cuda aware
189
- # implementation
190
- #
191
- if (EULER_KOKKOS_USE_MPI )
192
-
193
- if (MPI_FOUND
194
- AND (EULER_KOKKOS_BACKEND MATCHES "Cuda" )
195
- AND (NOT MPI_CUDA_AWARE_ENABLED ))
196
-
197
- message (FATAL_ERROR "You must use a cuda-aware MPI implementation." )
198
-
199
- endif ()
200
-
201
- endif ()
202
-
203
- #
204
- # common flags
205
- #
206
-
207
- if (EULER_KOKKOS_USE_DOUBLE )
208
- add_compile_options (-DUSE_DOUBLE )
209
- endif ()
210
-
211
- if (EULER_KOKKOS_USE_MPI )
212
- add_compile_options (-DUSE_MPI )
213
- endif ()
214
-
215
- if (EULER_KOKKOS_USE_FPE_DEBUG )
216
- add_compile_options (-DUSE_FPE_DEBUG )
217
- endif ()
218
-
219
156
#
220
157
# Using flags -Wextra, it's to strong for Kokkos, too many warnings But -Wall is
221
158
# really a minimum
@@ -225,6 +162,11 @@ endif()
225
162
# -pedantic ) add_definitions( -Wall -Wextra )
226
163
add_definitions (-Wall )
227
164
165
+ # Generate euler_kokkos_config.h and euler_kokkos_version.h (with git info and
166
+ # build date)
167
+ #
168
+ include (cmake/generate_config_h.cmake )
169
+
228
170
#
229
171
# sources
230
172
#
0 commit comments