-
Notifications
You must be signed in to change notification settings - Fork 12
/
CMakeLists.txt
107 lines (85 loc) · 3.84 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
############################ BASE ######################################
cmake_minimum_required (VERSION 3.14 FATAL_ERROR)
project(REMORA CXX C)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/CMake")
include(CMakePackageConfigHelpers)
########################## OPTIONS #####################################
#General options for all executables in the project
set(REMORA_DIM "3" CACHE STRING "Number of physical dimensions")
option(REMORA_ENABLE_DOCUMENTATION "Build documentation" OFF)
option(REMORA_ENABLE_ALL_WARNINGS "Enable all compiler warnings" OFF)
option(REMORA_ENABLE_TESTS "Enable regression and unit tests" OFF)
option(REMORA_ENABLE_PNETCDF "Enable PNetCDF IO" OFF)
option(REMORA_ENABLE_FCOMPARE "Enable building fcompare when not testing" OFF)
set(REMORA_PRECISION "DOUBLE" CACHE STRING "Floating point precision SINGLE or DOUBLE")
#Options for performance
option(REMORA_ENABLE_MPI "Enable MPI" OFF)
option(REMORA_ENABLE_OPENMP "Enable OpenMP" OFF)
option(REMORA_ENABLE_CUDA "Enable CUDA" OFF)
option(REMORA_ENABLE_HIP "Enable HIP" OFF)
option(REMORA_ENABLE_SYCL "Enable SYCL" OFF)
#Options for C++
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
if(REMORA_ENABLE_CUDA)
enable_language(CUDA)
if(CMAKE_CUDA_COMPILER_VERSION VERSION_LESS "9.0")
message(FATAL_ERROR "Your nvcc version is ${CMAKE_CUDA_COMPILER_VERSION} which is unsupported."
"Please use CUDA toolkit version 9.0 or newer.")
endif()
endif()
if(NOT REMORA_DIM EQUAL 3)
message(FATAL_ERROR "REMORA is only supported in 3D.")
endif()
# Configure measuring code coverage in tests
option(CODECOVERAGE "Enable code coverage profiling" OFF)
if(CODECOVERAGE)
# Only supports GNU
if(NOT CMAKE_CXX_COMPILER_ID MATCHES GNU)
message(WARNING "CODECOVERAGE is only support with GNU Compilers. The current C++ compiler is ${CMAKE_CXX_COMPILER_ID}")
endif()
if(NOT CMAKE_C_COMPILER_ID MATCHES GNU)
message(WARNING "CODECOVERAGE is only support with GNU Compilers. The current C compiler is ${CMAKE_C_COMPILER_ID}")
endif()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --coverage")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --coverage")
endif()
########################### AMReX #####################################
set(AMREX_SUBMOD_LOCATION "${CMAKE_SOURCE_DIR}/Submodules/AMReX")
include(${CMAKE_SOURCE_DIR}/CMake/SetAmrexOptions.cmake)
list(APPEND CMAKE_MODULE_PATH "${AMREX_SUBMOD_LOCATION}/Tools/CMake")
########################### AMReX #####################################
add_subdirectory(${AMREX_SUBMOD_LOCATION})
########################## PNETCDF ##################################
if(REMORA_ENABLE_PNETCDF)
find_package (PNetCDF REQUIRED)
if(PNETCDF_FOUND)
message(STATUS "Found PNetCDF, PNETCDF_DIR = ${PNETCDF_DIR}")
message(STATUS " PNETCDF_INCLUDE_DIRS = ${PNETCDF_INCLUDE_DIRS}")
message(STATUS " PNETCDF_VERSION = ${PNETCDF_VERSION}")
message(STATUS " PNETCDF_LIBRARY_DIRS = ${PNETCDF_LIBRARY_DIRS}")
message(STATUS " PNETCDF_ROOT_DIR = ${PNETCDF_ROOT_DIR}")
endif()
endif()
########################### REMORA #####################################
if(REMORA_ENABLE_MPI)
find_package(MPI REQUIRED)
endif()
# General information about machine, compiler, and build type
message(STATUS "REMORA 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}")
# Turn on rpath stuff
include(${CMAKE_SOURCE_DIR}/CMake/SetRpath.cmake)
#Build REMORA executables and intermediate object library and link to amrex library
add_subdirectory(Exec)
if(REMORA_ENABLE_TESTS)
include(CTest)
add_subdirectory(Tests)
endif()
if(REMORA_ENABLE_DOCUMENTATION)
add_subdirectory(Docs)
endif()