-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
95 lines (73 loc) · 3.38 KB
/
CMakeLists.txt
File metadata and controls
95 lines (73 loc) · 3.38 KB
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
cmake_minimum_required(VERSION 3.17.0)
project(ModEM VERSION 0
DESCRIPTION "ModEM"
LANGUAGES Fortran)
enable_language(Fortran)
option(BUILD_MPI "Build MPI version of MPI" ON)
option(BUILD_HDF5 "Build with HDF5" OFF)
option(FG "Build the Fine-Grained ModEM Version - (Only compatiable with SP2)" OFF)
option(USE_C_TIMERS "Use the C timers in ModEM_timers" OFF)
set(FORWARD_FORMULATION "SP2" CACHE STRING "Set the forward formulation: < MF | SP | SP2 >")
set(MODEM_BUILD_DIMS "3D" CACHE STRING "Specify whether to build either the 2D or 3D versino of ModEM < 2D | 3D >")
set(BUILD_GPU "OFF" CACHE STRING "Specify whether to build GPU options: < OFF | CUDA | HIP >")
# 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)
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo")
endif()
set(SUPPORTED_FORWARD_FORMULATIONS "MF;SP;SP2")
set(SUPPORTED_MODEM_DIMS "2D;3D")
set(SUPPORTED_GPU_OPTS "off;OFF;CUDA;HIP")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}")
if (USE_C_TIMERS OR BUILD_HDF5)
enable_language(C)
endif()
if (NOT BUILD_GPU IN_LIST SUPPORTED_GPU_OPTS)
message(FATAL_ERROR "-DBUILD_GPU option ('${BUILD_GPU}') was not valid - choose from: ${SUPPORTED_GPU_OPTS}")
endif()
if (BUILD_GPU STREQUAL CUDA)
enable_language(CUDA)
# Turning CMAKE_CUDA_ARCHITECTURES to OFF will make
# nvcc target the lowest possible CUDA Compute Capability.
# But this will allow users to pass in their own desired Compute
# Capability via: -DCMAKE_CUDA_ARCHITECTURES=<option>.
# Options here can be: all, all-major, native, or a specific version(s): "35;50;72"
# Note: The removal of decimal places.
#
# One option here would be to use 'native', but on HPC systems, there might not be a
# GPU available where one compiles the code as they are only available on compute nodes,
# thus, we shouldn't use it here, but users can pass it in themselves.
if (NOT DEFINED CMAKE_CUDA_ARCHITECTURES)
set(CMAKE_CUDA_ARCHITECTURES OFF)
else()
set(CUDA_ARCHITECTURES $CMAKE_CUDA_ARCHITECTURES)
endif()
elseif (BUILD_GPU STREQUAL HIP)
enable_language(HIP)
endif()
if (NOT FORWARD_FORMULATION IN_LIST SUPPORTED_FORWARD_FORMULATIONS )
message(FATAL_ERROR "-DFORWARD_FORMULATION option ('${FORWARD_FORMULATION}') was not valid choose from: ${SUPPORTED_FORWARD_FORMULATIONS}")
endif()
if (NOT MODEM_BUILD_DIMS IN_LIST SUPPORTED_MODEM_DIMS)
message(FATAL_ERROR "-DMODEM_BUILD_DIMS option ('${MODEM_BUILD_DIMS}') was not valid choose from ${SUPPORTED_MODEM_DIMS}")
endif()
if (FG AND NOT FORWARD_FORMULATION STREQUAL SP2)
message(FATAL_ERROR "You cannot build 'FG' with '${FORWARD_FORMULATION}' - Only SP2: -DFG=on -DFORWARD_FORMULATION=SP2")
endif()
if (BUILD_MPI)
add_compile_definitions(MPI)
endif()
if (BUILD_HDF5)
add_compile_definitions(HDF5)
endif()
if (BUILD_GPU STREQUAL "CUDA")
add_compile_definitions(CUDA)
elseif (BUILD_GPU STREQUAL "HIP")
add_compile_definitions(HIP)
endif()
if (FG)
add_compile_definitions(FG)
endif()
# Source Code
add_subdirectory(f90)