forked from rapidsai/cuspatial
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
310 lines (251 loc) · 11.7 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
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
#=============================================================================
# Copyright (c) 2019-2023, NVIDIA CORPORATION.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#=============================================================================
cmake_minimum_required(VERSION 3.23.1 FATAL_ERROR)
include(../fetch_rapids.cmake)
include(rapids-cmake)
include(rapids-cpm)
include(rapids-cuda)
include(rapids-export)
include(rapids-find)
rapids_cuda_init_architectures(CUSPATIAL)
project(CUSPATIAL VERSION 23.06.00 LANGUAGES C CXX CUDA)
# Needed because GoogleBenchmark changes the state of FindThreads.cmake,
# causing subsequent runs to have different values for the `Threads::Threads` target.
# Setting this flag ensures `Threads::Threads` is the same value in first run and subsequent runs.
set(THREADS_PREFER_PTHREAD_FLAG ON)
# Must come after enable_language(CUDA)
# Use `-isystem <path>` instead of `-isystem=<path>`
# because the former works with clangd intellisense
set(CMAKE_INCLUDE_SYSTEM_FLAG_CUDA "-isystem ")
###################################################################################################
# - build options ---------------------------------------------------------------------------------
option(BUILD_SHARED_LIBS "Build cuSpatial shared libraries" ON)
option(USE_NVTX "Build with NVTX support" ON)
option(BUILD_TESTS "Configure CMake to build tests" OFF)
option(BUILD_BENCHMARKS "Configure CMake to build (google) benchmarks" OFF)
option(PER_THREAD_DEFAULT_STREAM "Build with per-thread default stream" OFF)
option(DISABLE_DEPRECATION_WARNING "Disable warnings generated from deprecated declarations." OFF)
# Option to enable line info in CUDA device compilation to allow introspection when profiling / memchecking
option(CUDA_ENABLE_LINEINFO "Enable the -lineinfo option for nvcc (useful for cuda-memcheck / profiler" OFF)
# cudart can be statically linked or dynamically linked. The python ecosystem wants dynamic linking
option(CUDA_STATIC_RUNTIME "Statically link the CUDA toolkit runtime and libraries" OFF)
message(STATUS "CUSPATIAL: Build with NVTX support: ${USE_NVTX}")
message(STATUS "CUSPATIAL: Configure CMake to build tests: ${BUILD_TESTS}")
message(STATUS "CUSPATIAL: Configure CMake to build (google) benchmarks: ${BUILD_BENCHMARKS}")
message(STATUS "CUSPATIAL: Build with per-thread default stream: ${PER_THREAD_DEFAULT_STREAM}")
message(STATUS "CUSPATIAL: Disable warnings generated from deprecated declarations: ${DISABLE_DEPRECATION_WARNING}")
message(STATUS "CUSPATIAL: Enable the -lineinfo option for nvcc (useful for cuda-memcheck / profiler: ${CUDA_ENABLE_LINEINFO}")
message(STATUS "CUSPATIAL: Statically link the CUDA toolkit runtime and libraries: ${CUDA_STATIC_RUNTIME}")
# Set a default build type if none was specified
rapids_cmake_build_type("Release")
set(CUSPATIAL_BUILD_TESTS ${BUILD_TESTS})
set(CUSPATIAL_BUILD_BENCHMARKS ${BUILD_BENCHMARKS})
set(CUSPATIAL_CXX_FLAGS "")
set(CUSPATIAL_CUDA_FLAGS "")
set(CUSPATIAL_CXX_DEFINITIONS "")
set(CUSPATIAL_CUDA_DEFINITIONS "")
# Set RMM logging level
set(RMM_LOGGING_LEVEL "INFO" CACHE STRING "Choose the logging level.")
set_property(CACHE RMM_LOGGING_LEVEL PROPERTY STRINGS "TRACE" "DEBUG" "INFO" "WARN" "ERROR" "CRITICAL" "OFF")
message(STATUS "CUSPATIAL: RMM_LOGGING_LEVEL = '${RMM_LOGGING_LEVEL}'.")
###################################################################################################
# - conda environment -----------------------------------------------------------------------------
rapids_cmake_support_conda_env(conda_env MODIFY_PREFIX_PATH)
###################################################################################################
# - compiler options ------------------------------------------------------------------------------
set(_ctk_static_suffix "")
if(CUDA_STATIC_RUNTIME)
set(_ctk_static_suffix "_static")
# Control legacy FindCUDA.cmake behavior too
set(CUDA_USE_STATIC_CUDA_RUNTIME ON)
endif()
rapids_cuda_init_runtime(USE_STATIC ${CUDA_STATIC_RUNTIME})
rapids_find_package(
CUDAToolkit REQUIRED
BUILD_EXPORT_SET cuspatial-exports
INSTALL_EXPORT_SET cuspatial-exports
)
# * find CUDAToolkit package
# * determine GPU architectures
# * enable the CMake CUDA language
# * set other CUDA compilation flags
include(cmake/Modules/ConfigureCUDA.cmake)
###################################################################################################
# - dependencies ----------------------------------------------------------------------------------
# add third party dependencies using CPM
rapids_cpm_init()
# find or add cuDF
include(cmake/thirdparty/CUSPATIAL_GetCUDF.cmake)
# find or install GoogleTest
if (CUSPATIAL_BUILD_TESTS)
include(cmake/thirdparty/get_gtest.cmake)
endif()
###################################################################################################
# - library targets -------------------------------------------------------------------------------
add_library(cuspatial
src/column/geometry_column_view.cpp
src/indexing/construction/point_quadtree.cu
src/join/quadtree_point_in_polygon.cu
src/join/quadtree_point_to_nearest_linestring.cu
src/join/quadtree_bbox_filtering.cu
src/spatial/pairwise_multipoint_equals_count.cu
src/spatial/polygon_bounding_box.cu
src/spatial/linestring_bounding_box.cu
src/spatial/point_in_polygon.cu
src/spatial/pairwise_point_in_polygon.cu
src/spatial_window/spatial_window.cu
src/spatial/haversine.cu
src/spatial/hausdorff.cu
src/spatial/linestring_distance.cu
src/spatial/linestring_intersection.cu
src/spatial/point_distance.cu
src/spatial/point_linestring_distance.cu
src/spatial/point_polygon_distance.cu
src/spatial/point_linestring_nearest_points.cu
src/spatial/sinusoidal_projection.cu
src/trajectory/derive_trajectories.cu
src/trajectory/trajectory_bounding_boxes.cu
src/trajectory/trajectory_distances_and_speeds.cu
)
set_target_properties(cuspatial
PROPERTIES BUILD_RPATH "\$ORIGIN"
INSTALL_RPATH "\$ORIGIN"
# set target compile options
CXX_STANDARD 17
CXX_STANDARD_REQUIRED ON
CUDA_STANDARD 17
CUDA_STANDARD_REQUIRED ON
POSITION_INDEPENDENT_CODE ON
INTERFACE_POSITION_INDEPENDENT_CODE ON
)
target_compile_options(cuspatial
PRIVATE "$<$<COMPILE_LANGUAGE:CXX>:${CUSPATIAL_CXX_FLAGS}>"
"$<$<COMPILE_LANGUAGE:CUDA>:${CUSPATIAL_CUDA_FLAGS}>"
)
target_compile_definitions(cuspatial
PUBLIC "$<$<COMPILE_LANGUAGE:CXX>:${CUSPATIAL_CXX_DEFINITIONS}>"
"$<BUILD_INTERFACE:$<$<COMPILE_LANGUAGE:CUDA>:${CUSPATIAL_CUDA_DEFINITIONS}>>"
)
# Disable Jitify log printing. See https://github.com/NVIDIA/jitify/issues/79
target_compile_definitions(cuspatial PRIVATE "JITIFY_PRINT_LOG=0")
# Specify include paths for the current target and dependents
target_include_directories(cuspatial
PUBLIC "$<BUILD_INTERFACE:${CUSPATIAL_SOURCE_DIR}/include>"
PRIVATE "$<BUILD_INTERFACE:${CUSPATIAL_SOURCE_DIR}/src>"
INTERFACE "$<INSTALL_INTERFACE:include>")
# Add Conda library paths if specified
if(CONDA_LINK_DIRS)
target_link_directories(cuspatial PUBLIC "$<BUILD_INTERFACE:${CONDA_LINK_DIRS}>")
endif()
# Add Conda include paths if specified
if(CONDA_INCLUDE_DIRS)
target_include_directories(cuspatial PUBLIC "$<BUILD_INTERFACE:${CONDA_INCLUDE_DIRS}>")
endif()
# Per-thread default stream
if(PER_THREAD_DEFAULT_STREAM)
target_compile_definitions(cuspatial PUBLIC CUDA_API_PER_THREAD_DEFAULT_STREAM)
endif()
# Disable NVTX if necessary
if(NOT USE_NVTX)
target_compile_definitions(cuspatial PUBLIC NVTX_DISABLE)
endif()
# Define spdlog level
target_compile_definitions(cuspatial PUBLIC "SPDLOG_ACTIVE_LEVEL=SPDLOG_LEVEL_${RMM_LOGGING_LEVEL}")
# Specify the target module library dependencies
target_link_libraries(cuspatial PUBLIC cudf::cudf)
add_library(cuspatial::cuspatial ALIAS cuspatial)
###################################################################################################
# - add tests -------------------------------------------------------------------------------------
if(CUSPATIAL_BUILD_TESTS)
# include CTest module -- automatically calls enable_testing()
include(CTest)
add_subdirectory(tests)
endif()
###################################################################################################
# - add benchmarks --------------------------------------------------------------------------------
if(CUSPATIAL_BUILD_BENCHMARKS)
# Find or install GoogleBench
CPMFindPackage(NAME benchmark
VERSION 1.5.2
GIT_REPOSITORY https://github.com/google/benchmark.git
GIT_TAG v1.5.2
GIT_SHALLOW TRUE
OPTIONS "BENCHMARK_ENABLE_TESTING OFF"
"BENCHMARK_ENABLE_INSTALL OFF")
# Find or install NVBench Temporarily force downloading of fmt because current versions of nvbench
# do not support the latest version of fmt, which is automatically pulled into our conda
# environments by mamba.
set(CPM_DOWNLOAD_fmt TRUE)
include(${rapids-cmake-dir}/cpm/nvbench.cmake)
rapids_cpm_nvbench()
add_subdirectory(benchmarks)
endif()
###################################################################################################
# - install targets -------------------------------------------------------------------------------
rapids_cmake_install_lib_dir(lib_dir)
include(CPack)
include(GNUInstallDirs)
set(CMAKE_INSTALL_DEFAULT_COMPONENT_NAME cuspatial)
install(TARGETS cuspatial
DESTINATION ${lib_dir}
EXPORT cuspatial-exports)
install(DIRECTORY ${CUSPATIAL_SOURCE_DIR}/include/cuspatial
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
set(doc_string
[=[
Provide targets for the cuSpatial library.
cuSpatial is a GPU-accelerated library for spatial data management and analytics.
Imported Targets
^^^^^^^^^^^^^^^^
If cuspatial is found, this module defines the following IMPORTED GLOBAL
targets:
cuspatial::cuspatial - The main cuspatial library.
]=]
)
rapids_export(
INSTALL cuspatial
EXPORT_SET cuspatial-exports
GLOBAL_TARGETS cuspatial
NAMESPACE cuspatial::
DOCUMENTATION doc_string
)
################################################################################################
# - build export -------------------------------------------------------------------------------
rapids_export(
BUILD cuspatial
EXPORT_SET cuspatial-exports
GLOBAL_TARGETS cuspatial
NAMESPACE cuspatial::
DOCUMENTATION doc_string
)
# ##################################################################################################
# * build documentation ----------------------------------------------------------------------------
find_package(Doxygen)
if(DOXYGEN_FOUND)
# doc targets for cuSpatial
add_custom_command(
OUTPUT CUSPATIAL_DOXYGEN
WORKING_DIRECTORY ${CUSPATIAL_SOURCE_DIR}/doxygen
COMMAND ${DOXYGEN_EXECUTABLE} Doxyfile
VERBATIM
COMMENT "Custom command for building cuspatial doxygen docs."
)
add_custom_target(
docs_cuspatial
DEPENDS CUSPATIAL_DOXYGEN
COMMENT "Custom command for building cuspatial doxygen docs."
)
endif()