forked from LLNL/AMG2023
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
108 lines (89 loc) · 2.65 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
cmake_minimum_required(VERSION 3.21)
project (amg2023 C)
# Version information
set(AMG2023_MAJOR_VERSION 1)
set(AMG2023_MINOR_VERSION 0)
set(AMG2023_PATCH_VERSION 0)
set(AMG2023_VERSION "${AMG2023_MAJOR_VERSION}.${AMG2023_MINOR_VERSION}.${AMG2023_PATCH_VERSION}")
## Fail if someone tries to config an in-source build.
if("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}")
message(FATAL_ERROR "In-source builds are not supported. Please remove "
"CMakeCache.txt from the 'src' dir and configure an "
"out-of-source build in another directory.")
endif()
add_definitions(-DAMG_CMAKE_BUILD=1)
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
option(AMG_WITH_MPI "Use MPI" TRUE)
option(AMG_WITH_CUDA "Use CUDA" FALSE)
option(AMG_WITH_HIP "Use HIP" FALSE)
option(AMG_WITH_CALIPER "Enable Caliper" FALSE)
option(AMG_WITH_OMP "Enable OpenMP" FALSE)
option(AMG_WITH_UMPIRE "Enable Umpire support (requires Umpire support in HYPRE)" FALSE)
find_library(HYPRE_LIBRARIES
NAMES HYPRE
HINTS ${HYPRE_PREFIX}/lib)
find_path(HYPRE_INCLUDE_DIR
NAMES HYPRE.h
HINTS ${HYPRE_PREFIX}/include)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(HYPRE DEFAULT_MSG
HYPRE_LIBRARIES
HYPRE_INCLUDE_DIR)
if (NOT HYPRE_FOUND)
message(FATAL_ERROR "Hypre not found")
endif()
add_definitions(-DHYPRE_TIMING)
include_directories(${HYPRE_INCLUDE_DIR})
list(APPEND AMG_DEPENDENCIES
${HYPRE_LIBRARIES})
if (AMG_WITH_CUDA)
find_package(CUDAToolkit REQUIRED)
list(APPEND AMG_DEPENDENCIES
CUDA::cudart
CUDA::cublas
CUDA::cusparse
CUDA::curand)
endif()
if (AMG_WITH_HIP)
enable_language(CXX)
find_package(hip REQUIRED)
find_package(rocsparse REQUIRED)
find_package(rocrand REQUIRED)
list(APPEND AMG_DEPENDENCIES
hip::device
hip::host
roc::rocsparse
roc::rocrand)
endif()
if (AMG_WITH_CALIPER)
find_package(caliper REQUIRED)
list(APPEND AMG_DEPENDENCIES
caliper)
set(USE_CALIPER TRUE)
find_package(adiak REQUIRED)
list(APPEND AMG_DEPENDENCIES
adiak::adiak)
endif()
if (AMG_WITH_OMP)
find_package(OpenMP REQUIRED)
list(APPEND AMG_DEPENDENCIES
OpenMP::OpenMP_C)
endif()
if (AMG_WITH_MPI)
find_package(MPI REQUIRED)
list(APPEND AMG_DEPENDENCIES
MPI::MPI_C)
endif()
if (AMG_WITH_UMPIRE)
find_package(umpire REQUIRED)
list(APPEND AMG_DEPENDENCIES
umpire)
endif()
configure_file(
"${CMAKE_SOURCE_DIR}/amg-config.h.in"
"${CMAKE_BINARY_DIR}/amg-config.h"
)
add_executable(amg amg.c)
target_link_libraries(amg PUBLIC ${AMG_DEPENDENCIES} m)
target_include_directories(amg PUBLIC ${CMAKE_BINARY_DIR})
install(TARGETS amg DESTINATION ${CMAKE_INSTALL_BINDIR})