forked from NVIDIA/cuBQL
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
149 lines (127 loc) · 5.22 KB
/
CMakeLists.txt
File metadata and controls
149 lines (127 loc) · 5.22 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
# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA
# CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
cmake_minimum_required(VERSION 3.16)
set(CUBQL_VERSION_MAJOR 1)
set(CUBQL_VERSION_MINOR 3)
set(CUBQL_VERSION_PATCH 0)
set(CUBQL_VERSION ${CUBQL_VERSION_MAJOR}.${CUBQL_VERSION_MINOR}.${CUBQL_VERSION_PATCH})
cmake_policy(SET CMP0048 NEW)
set(CMAKE_BUILD_TYPE_INIT "Release")
project(cuBQL VERSION ${CUBQL_VERSION} LANGUAGES C CXX)
if (CUBQL_OMP)
set(CUBQL_DISABLE_CUDA ON)
endif()
if (CUBQL_DISABLE_CUDA)
message("#cuBQL: CUDA _DISABLED_ by user request")
set(CUBQL_HAVE_CUDA OFF)
else()
if (NOT CMAKE_CUDA_COMPILER)
include(CheckLanguage)
check_language(CUDA)
endif()
if (CMAKE_CUDA_COMPILER)
message("#cuBQL: CUDA _FOUND_! building both cuda and host libs")
enable_language(CUDA)
set(CUBQL_HAVE_CUDA ON)
else()
message(AUTHOR_WARNING
" ===========================================================\n"
" #cuBQL: could not find CUDA - going to build only host libs\n"
" ===========================================================\n"
)
set(CUBQL_HAVE_CUDA OFF)
endif()
endif()
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
if(${CMAKE_VERSION} VERSION_GREATER_EQUAL 3.18)
cmake_policy(SET CMP0104 NEW)
endif()
if (NOT (${CMAKE_CURRENT_SOURCE_DIR} STREQUAL ${CMAKE_SOURCE_DIR}))
set(CUBQL_IS_SUBPROJECT ON)
else()
set(CUBQL_IS_SUBPROJECT OFF)
endif()
# ------------------------------------------------------------------
# check if we're a subproject, and if so, only include the library
# itself
# ------------------------------------------------------------------
if (CUBQL_IS_SUBPROJECT)
# ------------------------------------------------------------------
# we're included from a parent project; it's this parent project's
# job to project-specific configs like configure output paths and
# build type, and to set CUQBL_CUDA_ARCHITECTURES to whatever
# arch(s) the project wants us to build for.
#
# Check if CUBQL_CUDA_ARCHITECTURES is set, and throw an error if
# not
# ------------------------------------------------------------------
if (CUBQL_HAVE_CUDA AND (NOT CMAKE_CUDA_ARCHITECTURES)
OR
((${CMAKE_VERSION} VERSION_LESS 3.24) AND ("${CMAKE_CUDA_ARCHITECTURES}" STREQUAL "52"))
)
message(FATAL_ERROR
" =====================================================================\n"
" #cuBQL: you've included cuBQL as a subproject (as it should!),\n"
" but CMAKE_CUDA_ARCHITECTURES was not set. As it is\n"
" almost certainly going to cause some problems in your project\n"
" if we were to just build cuBQL for archs different than your own\n"
" project's we will cowardly refuse do so. Before including cuBQL\n"
" you should explicitly set the cmake variable\n"
" CMAKE_CUDA_ARCHITECTURES to whatever the main project will want\n"
" to use, too.\n"
" \n"
" If in doubt as to what to use, at least for cmake >= 3.24 you can also use\n"
" set(CMAKE_CUDA_ARCHITECTURES \"all-major\")\n"
" add_subdirectory(<path-to-cubql) ...)\n"
" or\n"
" set(CMAKE_CUDA_ARCHITECTURES \"native\")\n"
" add_subdirectory(<path-to-cubql) ...)\n"
"====================================================================="
)
endif()
else()
if (CMAKE_CUDA_ARCHITECTURES)
# set on the cmdline, for a local build
set(CUBQL_CUDA_ARCHITECTURES_INIT "${CMAKE_CUDA_ARCHITECTURES}")
elseif (${CMAKE_VERSION} VERSION_LESS 3.24)
message(AUTHOR_WARNING
"====================================================================="
"\n"
"cuBQL: you're building with cmake version < 3.24, which doesn't
yet support the 'native' flag for CMAKE_CUDA_ARCHITECTURES.
We're defaulting to '70;80'; if that doesn't capture the kind of
GPU you are using, please either specify whatever arch(s) you
want to build for, or use a newer cmake for which we'll default
to 'native'"
"\n"
"====================================================================="
)
set(CUBQL_CUDA_ARCHITECTURES_INIT "70;80")
else()
set(CUBQL_CUDA_ARCHITECTURES_INIT "native")
endif()
set(CUBQL_CUDA_ARCHITECTURES "${CUBQL_CUDA_ARCHITECTURES_INIT}" CACHE STRING
"Which CUDA architecture to build for")
set(CMAKE_CUDA_ARCHITECTURES "${CUBQL_CUDA_ARCHITECTURES}")
if(CMAKE_CONFIGURATION_TYPES) # multiconfig generator?
set(CMAKE_CONFIGURATION_TYPES "Debug;Release" CACHE STRING "" FORCE)
else()
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release CACHE STRING "" FORCE)
endif()
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY HELPSTRING "Choose the type of build")
# set the valid options for cmake-gui drop-down list
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug;Release")
endif()
SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
endif()
message("#cuBQL: compiling with CMAKE_CUDA_ARCHITECTURES=${CMAKE_CUDA_ARCHITECTURES}")
add_subdirectory(cuBQL)
if (NOT CUBQL_IS_SUBPROJECT)
add_subdirectory(samples)
endif()
#add_subdirectory(testing)