-
Notifications
You must be signed in to change notification settings - Fork 39
/
CMakeLists.txt
207 lines (183 loc) · 8.13 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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
cmake_minimum_required(VERSION 3.16)
project(ArborX CXX)
if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.30.0)
message(STATUS "Setting policy CMP0167 to use FindBoost module")
cmake_policy(SET CMP0167 OLD)
endif()
# use gnu standard install directories
include(GNUInstallDirs)
find_package(Kokkos 4.3 REQUIRED CONFIG)
message(STATUS "Found Kokkos: ${Kokkos_DIR} (version \"${Kokkos_VERSION}\")")
# We use minimum compiler versions from Kokkos, with the exception for NVCC (>= 11.5)
if(Kokkos_CXX_COMPILER_ID STREQUAL "NVIDIA" AND Kokkos_CXX_COMPILER_VERSION VERSION_LESS 11.5.0)
message(FATAL_ERROR "NVCC versions prior to 11.5 are not supported by ArborX")
endif()
add_library(ArborX INTERFACE)
target_link_libraries(ArborX INTERFACE Kokkos::kokkos)
set_target_properties(ArborX PROPERTIES INTERFACE_COMPILE_FEATURES cxx_std_17)
# As all executables using ArborX depend on it, depending on record_hash allows
# updating hash each time executable is rebuilt, including when called from
# within a subdirectory.
add_dependencies(ArborX record_hash)
include(CMakeDependentOption)
cmake_dependent_option(ARBORX_ENABLE_ROCTHRUST "Enable rocThrust support" ON "Kokkos_ENABLE_HIP" OFF)
if(Kokkos_ENABLE_HIP AND ARBORX_ENABLE_ROCTHRUST)
find_package(rocthrust REQUIRED CONFIG)
target_link_libraries(ArborX INTERFACE roc::rocthrust)
endif()
if(Kokkos_ENABLE_HIP AND NOT ARBORX_ENABLE_ROCTHRUST)
message(WARNING "rocThrust is NOT enabled.\nThis will negatively impact performance on AMD GPUs.")
endif()
cmake_dependent_option(ARBORX_ENABLE_ONEDPL "Enable oneDPL support" ON "Kokkos_ENABLE_SYCL" OFF)
if(Kokkos_ENABLE_SYCL AND ARBORX_ENABLE_ONEDPL)
include(CheckIncludeFileCXX)
check_include_file_cxx(oneapi/dpl/execution ARBORX_COMPILER_HAS_ONEDPL_EXECUTION_HEADER)
check_include_file_cxx(oneapi/dpl/algorithm ARBORX_COMPILER_HAS_ONEDPL_ALGORITHM_HEADER)
if (ARBORX_COMPILER_HAS_ONEDPL_EXECUTION_HEADER AND
ARBORX_COMPILER_HAS_ONEDPL_ALGORITHM_HEADER)
set(ARBORX_CXX_COMPILER_BUNDLED_ONEDPL TRUE)
else()
set(ARBORX_CXX_COMPILER_BUNDLED_ONEDPL FALSE)
endif()
if(NOT ARBORX_CXX_COMPILER_BUNDLED_ONEDPL)
find_package(oneDPL REQUIRED)
target_link_libraries(ArborX INTERFACE oneDPL)
endif()
endif()
# Refer to the alias target in examples and benchmarks so they can be built
# against an installed ArborX
add_library(ArborX::ArborX ALIAS ArborX)
option(ARBORX_ENABLE_MPI "Enable MPI support" OFF)
if(ARBORX_ENABLE_MPI)
find_package(MPI REQUIRED)
target_link_libraries(ArborX INTERFACE MPI::MPI_CXX)
endif()
cmake_dependent_option(ARBORX_ENABLE_CUDA_AWARE_MPI
"Allow using device data in MPI communication"
OFF "ARBORX_ENABLE_MPI" OFF)
if(ARBORX_USE_CUDA_AWARE_MPI)
set(ARBORX_ENABLE_GPU_AWARE_MPI ON)
message(DEPRECATION "ARBORX_USE_CUDA_AWARE_MPI is deprecated, use ARBORX_ENABLE_GPU_AWARE_MPI instead")
endif()
cmake_dependent_option(ARBORX_ENABLE_GPU_AWARE_MPI
"Allow using device data in MPI communication"
OFF "ARBORX_ENABLE_MPI" OFF)
target_include_directories(ArborX INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/geometry>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/cluster>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/distributed>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/interpolation>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/spatial>
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/include>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/ArborX>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/ArborX/geometry>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/ArborX/cluster>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/ArborX/distributed>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/ArborX/interpolation>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/ArborX/spatial>
)
install(TARGETS ArborX
EXPORT ArborXTargets
ARCHIVE LIBRARY PUBLIC_HEADER
)
install(EXPORT ArborXTargets
NAMESPACE ArborX::
DESTINATION ${CMAKE_INSTALL_DATADIR}/cmake/ArborX
)
set(ARBORX_VERSION "10799")
set(ARBORX_VERSION_STRING "2.0 (dev)")
# Make sure that the git hash in ArborX_Version.hpp is considered to be always
# out of date, and thus is updated every recompile.
add_custom_target(
record_hash ALL VERBATIM
COMMAND ${CMAKE_COMMAND}
-DSOURCE_DIR=${CMAKE_CURRENT_SOURCE_DIR}
-DBINARY_DIR=${CMAKE_CURRENT_BINARY_DIR}
-DARBORX_VERSION_STRING=${ARBORX_VERSION_STRING}
-P cmake/SetupVersion.cmake
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
# Also run the record_hash command during configuration stage to have a visible
# ArborX_Version.hpp at all times.
execute_process(
COMMAND ${CMAKE_COMMAND}
-DSOURCE_DIR=${CMAKE_CURRENT_SOURCE_DIR}
-DBINARY_DIR=${CMAKE_CURRENT_BINARY_DIR}
-DARBORX_VERSION_STRING=${ARBORX_VERSION_STRING}
-P cmake/SetupVersion.cmake
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/src/ArborX_Config.hpp.in
${CMAKE_CURRENT_BINARY_DIR}/include/ArborX_Config.hpp)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/ArborXSettings.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/ArborXSettings.cmake
@ONLY)
include(CMakePackageConfigHelpers)
configure_package_config_file(cmake/ArborXConfig.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/ArborXConfig.cmake
INSTALL_DESTINATION ${CMAKE_INSTALL_DATADIR}/cmake/ArborX
)
write_basic_package_version_file(${CMAKE_CURRENT_BINARY_DIR}/ArborXConfigVersion.cmake
VERSION ${ARBORX_VERSION_STRING}
COMPATIBILITY AnyNewerVersion
)
install(FILES
${CMAKE_CURRENT_BINARY_DIR}/ArborXConfig.cmake
${CMAKE_CURRENT_BINARY_DIR}/ArborXConfigVersion.cmake
${CMAKE_CURRENT_BINARY_DIR}/ArborXSettings.cmake
DESTINATION ${CMAKE_INSTALL_DATADIR}/cmake/ArborX )
if(ARBORX_ENABLE_MPI)
install(DIRECTORY ${PROJECT_SOURCE_DIR}/src/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/ArborX
FILES_MATCHING PATTERN "*.hpp")
else()
install(DIRECTORY ${PROJECT_SOURCE_DIR}/src/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/ArborX
FILES_MATCHING PATTERN "*.hpp"
PATTERN "*Distribut*" EXCLUDE)
endif()
install(DIRECTORY ${PROJECT_BINARY_DIR}/include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/ArborX
FILES_MATCHING PATTERN "*.hpp")
if(NOT CMAKE_BUILD_TYPE)
set(default_build_type "RelWithDebInfo")
message(STATUS "Setting build type to '${default_build_type}' as none was specified.")
set(CMAKE_BUILD_TYPE "${default_build_type}" CACHE STRING
"Choose the type of build, options are: Debug, Release, RelWithDebInfo and MinSizeRel."
FORCE)
endif()
option(ARBORX_ENABLE_TESTS "Enable tests" OFF)
option(ARBORX_ENABLE_EXAMPLES "Enable examples" OFF)
option(ARBORX_ENABLE_BENCHMARKS "Enable benchmarks" OFF)
if(ARBORX_ENABLE_TESTS OR ARBORX_ENABLE_EXAMPLES OR ARBORX_ENABLE_BENCHMARKS)
enable_testing()
endif()
cmake_dependent_option(ARBORX_ENABLE_HEADER_SELF_CONTAINMENT_TESTS "Enable header self-containment unit tests" ON "ARBORX_ENABLE_TESTS" OFF)
if(ARBORX_ENABLE_HEADER_SELF_CONTAINMENT_TESTS)
# Globbing all the header filenames to test for self-containment and presence of header guards
file(GLOB_RECURSE ArborX_HEADERS RELATIVE ${CMAKE_SOURCE_DIR}/src src/*.hpp)
# Findout what headers are using macros defined in ArborX_Config.hpp
file(STRINGS src/ArborX_Config.hpp.in ArborX_DEFINITIONS REGEX "define ARBORX_")
foreach(_definition ${ArborX_DEFINITIONS})
string(REGEX REPLACE "(#define |#cmakedefine )" "" _macro ${_definition})
list(APPEND ArborX_MACROS ${_macro})
endforeach()
foreach(_file ${ArborX_HEADERS})
foreach(_macro ${ArborX_MACROS})
file(STRINGS src/${_file} _includes_mpi REGEX "mpi.h")
if(_includes_mpi)
list(APPEND ArborX_HEADERS_MUST_ENABLE_MPI ${_file})
endif()
file(STRINGS src/${_file} _has_macro REGEX "${_macro}")
if(_has_macro)
list(APPEND ArborX_HEADERS_MUST_INCLUDE_CONFIG_HPP ${_file})
continue()
endif()
endforeach()
endforeach()
endif()
if(ARBORX_ENABLE_TESTS)
add_subdirectory(test)
endif()
if(ARBORX_ENABLE_EXAMPLES)
add_subdirectory(examples)
endif()
if(ARBORX_ENABLE_BENCHMARKS)
add_subdirectory(benchmarks)
endif()