forked from NVIDIA/cuCollections
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
195 lines (154 loc) · 7.71 KB
/
CMakeLists.txt
File metadata and controls
195 lines (154 loc) · 7.71 KB
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
#=============================================================================
# Copyright (c) 2018-2025, 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)
set(rapids-cmake-version 25.12)
if(NOT EXISTS ${CMAKE_CURRENT_BINARY_DIR}/CUCO_RAPIDS.cmake)
file(DOWNLOAD
https://raw.githubusercontent.com/rapidsai/rapids-cmake/release/${rapids-cmake-version}/RAPIDS.cmake
${CMAKE_CURRENT_BINARY_DIR}/CUCO_RAPIDS.cmake)
endif()
include(${CMAKE_CURRENT_BINARY_DIR}/CUCO_RAPIDS.cmake)
include(rapids-cmake)
include(rapids-cpm)
include(rapids-cuda)
include(rapids-export)
include(rapids-find)
# * Determine GPU architectures
# * Enable the CMake CUDA language
rapids_cuda_init_architectures(CUCO)
project(CUCO VERSION 0.0.1 LANGUAGES CXX CUDA)
###################################################################################################
# - build options ---------------------------------------------------------------------------------
set(default_build_option_state OFF)
if ("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_LIST_DIR}")
set(default_build_option_state ON)
endif()
option(BUILD_TESTS "Configure CMake to build tests" ${default_build_option_state})
option(BUILD_BENCHMARKS "Configure CMake to build (google) benchmarks" ${default_build_option_state})
option(BUILD_EXAMPLES "Configure CMake to build examples" ${default_build_option_state})
option(INSTALL_CUCO "Enable CMake install rules for cuco" ${default_build_option_state})
# Write the version header
rapids_cmake_write_version_file(include/cuco/version_config.hpp)
##############################################################################
# - build type ---------------------------------------------------------------
# Set a default build type if none was specified
rapids_cmake_build_type(Release)
# needed for clangd and clang-tidy
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
##############################################################################
# - compiler options ---------------------------------------------------------
# * Find CUDAToolkit package
# * Offers support for CMAKE_CUDA_ARCHITECTURES=NATIVE
rapids_find_package(
CUDAToolkit REQUIRED
BUILD_EXPORT_SET cuco-exports
INSTALL_EXPORT_SET cuco-exports
)
###################################################################################################
# - find packages we depend on --------------------------------------------------------------------
rapids_cpm_init()
include(cmake/thirdparty/get_cccl.cmake)
###################################################################################################
# - cuco target ---------------------------------------------------------------------------------
add_library(cuco INTERFACE)
add_library(cuco::cuco ALIAS cuco)
target_include_directories(cuco INTERFACE
INTERFACE $<BUILD_INTERFACE:${CUCO_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>)
target_link_libraries(cuco INTERFACE CCCL::CCCL CUDA::toolkit)
target_compile_features(cuco INTERFACE cxx_std_17 cuda_std_17)
###################################################################################################
# - Optionally download RoaringFormatSpec test data -----------------------------------------------
option(CUCO_DOWNLOAD_ROARING_TESTDATA "Download RoaringFormatSpec test data" ON)
include(${CMAKE_CURRENT_LIST_DIR}/cmake/roaring_testdata.cmake)
###################################################################################################
# - common compile options function ---------------------------------------------------------------
function(cuco_set_common_compile_options target_name)
# Parse optional arguments
cmake_parse_arguments(CUCO_OPTS "ADD_LINEINFO" "" "" ${ARGN})
# Base compile options common to all targets
target_compile_options(${target_name} PRIVATE
--compiler-options=-Wall --compiler-options=-Wextra --compiler-options=-Werror
-Wno-deprecated-gpu-targets --expt-extended-lambda -Werror=all-warnings
)
# Add lineinfo option if requested (typically for benchmarks)
if(CUCO_OPTS_ADD_LINEINFO)
target_compile_options(${target_name} PRIVATE -lineinfo)
endif()
# Add GCC-specific warning suppression only for GCC
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
target_compile_options(${target_name} PRIVATE -Xcompiler -Wno-subobject-linkage)
endif()
# Add Clang-specific warning suppression for deprecated literal operators
# (Catch2 and cuco code still use deprecated syntax)
# Only for Clang 15+ which introduced this warning
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 15.0)
target_compile_options(${target_name} PRIVATE -Xcompiler -Wno-deprecated-literal-operator)
endif()
endfunction()
###################################################################################################
# - optionally build tests ------------------------------------------------------------------------
if(BUILD_TESTS)
include(CTest)
add_subdirectory(tests)
# Include header tests as part of the regular test suite
include(cmake/header_testing.cmake)
endif(BUILD_TESTS)
###################################################################################################
# - Optionally build nvbench benchmarks -----------------------------------------------------------
if(BUILD_BENCHMARKS)
include(${rapids-cmake-dir}/cpm/nvbench.cmake)
include(${rapids-cmake-dir}/cpm/package_override.cmake)
rapids_cpm_nvbench(BUILD_STATIC)
add_subdirectory(benchmarks)
endif(BUILD_BENCHMARKS)
###################################################################################################
# - Optionally build examples ---------------------------------------------------------------------
if(BUILD_EXAMPLES)
add_subdirectory(examples)
endif(BUILD_EXAMPLES)
###################################################################################################
# - Install targets -------------------------------------------------------------------------------
install(TARGETS cuco EXPORT cuco-exports)
set(doc_string
[=[
Provide targets for cuCollections.
cuCollections (cuco) is an open-source, header-only library of GPU-accelerated,
concurrent data structures.
Similar to how Thrust and CUB provide STL-like, GPU accelerated algorithms and
primitives, cuCollections provides STL-like concurrent data structures.
cuCollections is not a one-to-one, drop-in replacement for STL data structures
like std::unordered_map. Instead, it provides functionally similar data
structures tailored for efficient use with GPUs.
]=])
# build directory cuco-config generation
rapids_export(
BUILD cuco
EXPORT_SET cuco-exports
GLOBAL_TARGETS cuco
NAMESPACE cuco::
DOCUMENTATION doc_string)
if(INSTALL_CUCO)
install(DIRECTORY include/cuco/ DESTINATION include/cuco)
install(FILES ${CUCO_BINARY_DIR}/include/cuco/version_config.hpp DESTINATION include/cuco)
# install directory cuco-config generation
rapids_export(
INSTALL cuco
EXPORT_SET cuco-exports
GLOBAL_TARGETS cuco
NAMESPACE cuco::
DOCUMENTATION doc_string)
endif()