forked from AMReX-Combustion/PeleC
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
142 lines (118 loc) · 5.18 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
############################ BASE ######################################
cmake_minimum_required (VERSION 3.14 FATAL_ERROR)
project(PeleC CXX C)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON CACHE INTERNAL "")
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/CMake")
include(CMakePackageConfigHelpers)
include(PeleCUtils)
########################## OPTIONS #####################################
#General options for all executables in the project
set(PELEC_DIM "3" CACHE STRING "Number of physical dimensions")
option(PELEC_ENABLE_AMREX_EB "Enable EB in AMReX library" ON)
option(PELEC_ENABLE_ALL_WARNINGS "Enable all compiler warnings" ON)
option(PELEC_ENABLE_CLANG_TIDY "Enable clang-tidy analysis" OFF)
option(PELEC_ENABLE_CPPCHECK "Enable cppcheck analysis" OFF)
option(PELEC_ENABLE_WERROR "Treat compiler warnings as errors" OFF)
option(PELEC_ENABLE_MASA "Enable tests that require MASA" OFF)
option(PELEC_ENABLE_SUNDIALS "Enable SUNDIALS as ODE solver" OFF)
option(PELEC_ENABLE_FCOMPARE "Enable building fcompare when not testing" OFF)
option(PELEC_ENABLE_TESTS "Enable regression and unit tests" OFF)
option(PELEC_ENABLE_FCOMPARE_FOR_TESTS "Check test plots against gold files" OFF)
option(PELEC_ENABLE_SANITIZE_FOR_TESTS "Currently only disables certain long running MMS tests if set" OFF)
option(PELEC_ENABLE_FPE_TRAP_FOR_TESTS "Enable FPE trapping in tests" ON)
option(PELEC_ENABLE_TINY_PROFILE "Enable tiny profiler in AMReX" OFF)
set(PELEC_PRECISION "DOUBLE" CACHE STRING "Floating point precision SINGLE or DOUBLE")
#Options for performance
option(PELEC_ENABLE_MPI "Enable MPI" OFF)
option(PELEC_ENABLE_OPENMP "Enable OpenMP" OFF)
option(PELEC_ENABLE_CUDA "Enable CUDA" OFF)
option(PELEC_ENABLE_HIP "Enable HIP" OFF)
option(PELEC_ENABLE_DPCPP "Enable DPC++" OFF)
#Options for C++
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
if(PELEC_ENABLE_TESTS AND PELEC_ENABLE_FCOMPARE_FOR_TESTS)
set(PELEC_ENABLE_FCOMPARE ON)
endif()
if(PELEC_ENABLE_CUDA)
enable_language(CUDA)
if(CMAKE_CUDA_COMPILER_VERSION VERSION_LESS "10.0")
message(FATAL_ERROR "Your nvcc version is ${CMAKE_CUDA_COMPILER_VERSION} which is unsupported."
"Please use CUDA toolkit version 10.0 or newer.")
endif()
if(PELEC_ENABLE_MASA)
message(FATAL_ERROR "MASA enabled with CUDA is unsupported.")
endif()
endif()
if((PELEC_DIM EQUAL 1) AND PELEC_ENABLE_AMREX_EB)
set(PELEC_ENABLE_AMREX_EB OFF)
message(WARNING "Disabling EB for ${PELEC_DIM}D.")
endif()
########################### AMReX #####################################
message(STATUS "AMReX Configure Section")
set(AMREX_SUBMOD_LOCATION "${CMAKE_SOURCE_DIR}/Submodules/AMReX")
include(SetAmrexOptions)
list(APPEND CMAKE_MODULE_PATH "${AMREX_SUBMOD_LOCATION}/Tools/CMake")
if(PELEC_ENABLE_CUDA)
include(AMReX_SetupCUDA)
endif()
add_subdirectory(${AMREX_SUBMOD_LOCATION})
include(SetAmrexCompileFlags)
########################### AMReX-Hydro ###############################
message(STATUS "AMReX-Hydro Configure Section")
set(AMREX_HYDRO_SUBMOD_LOCATION "${CMAKE_SOURCE_DIR}/Submodules/AMReX-Hydro")
########################## SUNDIALS ###################################
if(PELEC_ENABLE_SUNDIALS)
message(STATUS "SUNDIALS Configure Section")
if(NOT (PELEC_SUNDIALS_INTEGRATOR MATCHES "^(arkode|cvode)$"))
set(PELEC_SUNDIALS_INTEGRATOR arkode)
endif()
set(SUNDIALS_SUBMOD_LOCATION "${CMAKE_SOURCE_DIR}/Submodules/sundials")
include(SetSundialsOptions)
message(STATUS "SUNDIALS Integrator = ${PELEC_SUNDIALS_INTEGRATOR}")
#BUILD_TESTING is an old CMake keyword so don't clear it in sundials configure
set(CMAKE_POLICY_DEFAULT_CMP0077 NEW)
add_subdirectory(${SUNDIALS_SUBMOD_LOCATION})
endif()
########################### MASA #####################################
if(PELEC_ENABLE_MASA)
message(STATUS "MASA Configure Section")
set(CMAKE_PREFIX_PATH ${MASA_DIR} ${CMAKE_PREFIX_PATH})
find_package(MASA QUIET REQUIRED)
if(MASA_FOUND)
message(STATUS "Found MASA = ${MASA_DIR}")
endif()
endif()
########################### PeleC #####################################
if(PELEC_ENABLE_MPI)
message(STATUS "MPI Configure Section")
find_package(MPI REQUIRED)
endif()
# General information about machine, compiler, and build type
message(STATUS "PeleC Information:")
message(STATUS "CMAKE_SYSTEM_NAME = ${CMAKE_SYSTEM_NAME}")
message(STATUS "CMAKE_CXX_COMPILER_ID = ${CMAKE_CXX_COMPILER_ID}")
message(STATUS "CMAKE_CXX_COMPILER_VERSION = ${CMAKE_CXX_COMPILER_VERSION}")
message(STATUS "CMAKE_BUILD_TYPE = ${CMAKE_BUILD_TYPE}")
if(PELEC_ENABLE_WERROR)
message(STATUS "Enabling Werror.")
endif()
message(STATUS "PELEC_PRECISION = ${PELEC_PRECISION}")
if("${PELEC_PRECISION}" STREQUAL "SINGLE" AND PELEC_ENABLE_AMREX_EB)
message(FATAL_ERROR "Single precision currently not allowed in AMReX with EB enabled")
endif()
if("${PELEC_PRECISION}" STREQUAL "SINGLE" AND PELEC_ENABLE_MASA)
message(FATAL_ERROR "Single precision currently not allowed in AMReX with MASA enabled")
endif()
init_code_checks()
#Turn on rpath stuff
include(SetRpath)
#Build pelec executables and link to amrex library
add_subdirectory(Exec)
if(PELEC_ENABLE_TESTS)
enable_testing()
include(CTest)
add_subdirectory("Submodules/GoogleTest")
add_subdirectory(Tests)
endif()