This repository has been archived by the owner on Dec 22, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 15
/
CMakeLists.txt
221 lines (192 loc) · 7.12 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
####################################################
############ INSTALLING CORRECT CMAKE ##############
####################################################
# Installing correct cmake version is easy!
# 1) Find the respective version here;
# https://github.com/Kitware/CMake/releases,
# and 2) replace the [x.xx.x] in the following
# commands with the version number (remove the
# brackets). For example, if you are installing
# CMake 3.22.1, replace [x.xx.x] with 3.22.1:
# wget https://github.com/Kitware/CMake/releases/download/v[x.xx.x]/cmake-[x.xx.x]-linux-x86_64.sh
# chmod +x ./cmake-[x.xx.x]-linux-x86_64.sh
# ./cmake-[x.xx.x]-linux-x86_64.sh
# sudo mv cmake-[x.xx.x]-linux-x86_64 /opt/cmake
# sudo ln -s /opt/cmake/bin/* /usr/local/bin/
cmake_minimum_required(VERSION 3.20.1 FATAL_ERROR)
# begin /* Update Essentials version */
set(ESSENTIALS_VERSION_MAJOR 2)
set(ESSENTIALS_VERSION_MINOR 0)
set(ESSENTIALS_VERSION_PATCH 0)
# end /* Update Essentials version */
set(ESSENTIALS_VERSION "${ESSENTIALS_VERSION_MAJOR}.${ESSENTIALS_VERSION_MINOR}.${ESSENTIALS_VERSION_PATCH}")
project(essentials
VERSION ${ESSENTIALS_VERSION}
LANGUAGES CXX C CUDA
)
# begin /* Dependencies directory */
set(PROJECT_DEPS_DIR externals)
# end /* Dependencies directory */
# begin /* Include cmake modules */
include(${PROJECT_SOURCE_DIR}/cmake/FetchThrustCUB.cmake)
include(${PROJECT_SOURCE_DIR}/cmake/FetchModernGPU.cmake)
include(${PROJECT_SOURCE_DIR}/cmake/FetchCXXOpts.cmake)
include(${PROJECT_SOURCE_DIR}/cmake/FetchRapidJSON.cmake)
include(${PROJECT_SOURCE_DIR}/cmake/FetchNlohmannJson.cmake)
# end /* Include cmake modules */
## Set the directory where the binaries will be stored
set(EXECUTABLE_OUTPUT_PATH
${PROJECT_BINARY_DIR}/bin
CACHE PATH
"Directory where all executables will be stored")
## Set the directory where the libraries will be stored
set(LIBRARY_OUTPUT_PATH
${PROJECT_BINARY_DIR}/lib
CACHE PATH
"Directory where all the libraries will be stored")
## Export compile commands
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(CMAKE_VERBOSE_MAKEFILE OFF)
############ ADD LIBRARY: ESSENTIALS (HEADER-ONLY) ############
add_library(essentials INTERFACE)
####################################################
############### SET TARGET PROPERTIES ##############
####################################################
set_target_properties(essentials
PROPERTIES
CXX_STANDARD 17
CXX_STANDARD_REQUIRED ON
CXX_EXTENSIONS OFF # Should this be turned on for MSVC?
CUDA_STANDARD 17
CUDA_STANDARD_REQUIRED ON
CUDA_EXTENSIONS OFF
CUDA_RESOLVE_DEVICE_SYMBOLS ON
CUDA_SEPARABLE_COMPILATION ON
CUDA_ARCHITECTURES 75 # Set required architecture.
# CUDA_PTX_COMPILATION ON # Can only be applied to OBJ.
)
# Use for later.
get_target_property(ESSENTIALS_ARCHITECTURES
essentials
CUDA_ARCHITECTURES
)
####################################################
############ TARGET COMPILER DEFINITIONS ###########
####################################################
target_compile_definitions(essentials
INTERFACE
SM_TARGET=${ESSENTIALS_ARCHITECTURES}
ESSENTIALS_VERSION=${ESSENTIALS_VERSION}
)
message(STATUS "Essentials CUDA Architecture: ${ESSENTIALS_ARCHITECTURES}")
####################################################
############ TARGET COMPILE FEATURES ###############
####################################################
# Turn C++ Standard 17 ON.
target_compile_features(essentials INTERFACE cxx_std_17)
# set(CMAKE_CXX_EXTENSIONS OFF)
set(ESSENTIALS_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include)
####################################################
############ TARGET INCLUDE DIRECTORIES ############
####################################################
target_include_directories(essentials
INTERFACE ${ESSENTIALS_INCLUDE_DIR}
INTERFACE ${CXXOPTS_INCLUDE_DIR}
INTERFACE ${THRUST_INCLUDE_DIR}
INTERFACE ${CUB_INCLUDE_DIR}
INTERFACE ${MODERNGPU_INCLUDE_DIR}
INTERFACE ${RAPIDJSON_INCLUDE_DIR}
INTERFACE ${NHLOMANN_JSON_INCLUDE_DIR}
INTERFACE ${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES}
)
####################################################
############ TARGET LINK LIBRARIES #################
####################################################
target_link_libraries(essentials
INTERFACE curand
INTERFACE cuda
INTERFACE cusparse
)
####################################################
################# TARGET SOURCES ###################
####################################################
target_sources(essentials
INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/include/gunrock/util/gitsha1make.c"
INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/include/gunrock/io/detail/mmio.cpp"
)
####################################################
############## SET CXX & CUDA FLAGS ################
####################################################
set(CXX_FLAGS
$<$<CXX_COMPILER_ID:MSVC>:
/W4
>
$<$<CXX_COMPILER_ID:GNU>:
-Wall
# -Wextra
-Wno-unused-result
-Wno-unused-local-typedefs
-Wno-strict-aliasing
-Wno-unused-function
-Wno-format-security
# -Werror
# -vvv
>
)
set(CUDA_FLAGS
--expt-extended-lambda
--expt-relaxed-constexpr
--use_fast_math
--ptxas-options -v
--generate-line-info
$<$<CXX_COMPILER_ID:GNU>:-O3> # Host optimize-level
# --verbose
# --debug # Host debug
# --device-debug # Device debug
)
set(CMAKE_CUDA_FLAGS_DEBUG "--optimize 0 --debug --device-debug -g -G")
set(CMAKE_CUDA_FLAGS_RELEASE "--optimize 3")
####################################################
############ TARGET COMPILE OPTIONS ################
####################################################
target_compile_options(essentials INTERFACE
$<$<COMPILE_LANGUAGE:CXX>:${CXX_FLAGS}>
$<$<COMPILE_LANGUAGE:CUDA>:${CUDA_FLAGS}>
)
####################################################
############ BUILD EXAMPLE APPLICATIONS ############
####################################################
option(ESSENTIALS_BUILD_EXAMPLES
"If on, builds the example graph applications."
ON)
# Subdirectories for examples, testing and documentation
if(ESSENTIALS_BUILD_EXAMPLES)
add_subdirectory(examples)
endif(ESSENTIALS_BUILD_EXAMPLES)
####################################################
################ BUILD UNIT TESTS #################
####################################################
option(ESSENTIALS_BUILD_TESTS
"If on, builds the unit tests."
ON)
# Subdirectories for examples, testing and documentation
if(ESSENTIALS_BUILD_TESTS)
include(${PROJECT_SOURCE_DIR}/cmake/FetchGoogleTest.cmake)
enable_testing()
add_subdirectory(unittests)
endif(ESSENTIALS_BUILD_TESTS)
####################################################
################ BUILD BENCHMARKS #################
####################################################
option(ESSENTIALS_BUILD_BENCHMARKS
"If on, builds essentials with benchmarking support."
OFF)
# Subdirectories for examples, testing and documentation
if(ESSENTIALS_BUILD_BENCHMARKS)
# ... see https://github.com/NVIDIA/nvbench/issues/66
set(NVBench_ENABLE_NVML OFF)
# ... set cuda architecture for nvbench.
set(CMAKE_CUDA_ARCHITECTURES ${ESSENTIALS_ARCHITECTURES})
include(${PROJECT_SOURCE_DIR}/cmake/FetchNVBench.cmake)
add_subdirectory(benchmarks)
endif(ESSENTIALS_BUILD_BENCHMARKS)