-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCMakeLists.txt
99 lines (77 loc) · 2.79 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
cmake_minimum_required (VERSION 3.20)
project (CEDA-demonstrations C CXX)
# prohibit in-source build
if("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}")
message(FATAL_ERROR "In-source build prohibited.")
endif()
# default build type
set(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING "Build type")
# Show/hide compiler and flags based on the current build type
macro(show_language_flags lang)
set(_build_types DEBUG RELEASE RELWITHDEBINFO MINSIZEREL)
string(TOUPPER "${CMAKE_BUILD_TYPE}" _cmake_build_type)
foreach(build_type ${_build_types})
if(${_cmake_build_type} MATCHES "${build_type}")
message(STATUS "Appending ${lang} ${build_type} flags: ${CMAKE_${lang}_FLAGS_${build_type}}")
mark_as_advanced(CLEAR CMAKE_${lang}_FLAGS_${build_type})
else()
mark_as_advanced(FORCE CMAKE_${lang}_FLAGS_${build_type})
endif()
endforeach()
# show the language compiler and flags
mark_as_advanced(CLEAR CMAKE_${lang}_COMPILER CMAKE_${lang}_FLAGS)
# print implicit includes
message(STATUS "Implicit ${lang} includes: ${CMAKE_${lang}_IMPLICIT_INCLUDE_DIRECTORIES}")
endmacro()
# Simple function to add a given prefix to a list of files
function(add_prefix var prefix)
set(result)
foreach(item ${${var}})
list(APPEND result "${prefix}${item}")
endforeach()
set(${var} ${result} PARENT_SCOPE)
endfunction()
show_language_flags(CXX)
set(CMAKE_CXX_STANDARD "17" CACHE STRING "C++ standard to use")
# Append to the runtime search path (rpath) of installed binaries any
# directories outside the project that are in the linker search path or contain
# linked library files.
option(CMAKE_INSTALL_RPATH_USE_LINK_PATH "Set rpath" ON)
mark_as_advanced(FORCE CMAKE_INSTALL_RPATH_USE_LINK_PATH)
# set installation folders
set(demonstration_bin "${CMAKE_CURRENT_SOURCE_DIR}/bin")
# -------------
# Build options
# -------------
option(USE_CUDA "Use CUDA for GPU acceleration" OFF)
option(USE_HIP "Use HIP for GPU acceleration" OFF)
if(USE_CUDA)
enable_language(CUDA)
show_language_flags(CUDA)
set(CMAKE_CUDA_ARCHITECTURES "70" CACHE STRING "CUDA Architecture")
set(CMAKE_CUDA_STANDARD ${CMAKE_CXX_STANDARD})
endif()
# ----
# MPI
# ----
find_package(MPI REQUIRED)
# ---------
# SUNDIALS
# ---------
set(SUNDIALS_ROOT "$ENV{SUNDIALS_ROOT}"
CACHE PATH "Root directory of SUNDIALS install")
find_package(SUNDIALS REQUIRED
PATHS
"${SUNDIALS_ROOT}/lib64/cmake/sundials"
"${SUNDIALS_ROOT}/lib/cmake/sundials"
"${SUNDIALS_ROOT}")
message(STATUS "Found SUNDIALS: ${SUNDIALS_DIR}")
# -----
# HYPRE
# -----
option(USE_HYPRE "Use HYPRE for preconditioning" OFF)
# --------------------------------------------------------
# add subdirectories for specific demonstration test codes
# --------------------------------------------------------
add_subdirectory(diffusion_2D)
add_subdirectory(adr_1D)