forked from sleeepyjack/warpcore
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
98 lines (75 loc) · 3.85 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
cmake_minimum_required(VERSION 3.18 FATAL_ERROR)
project(warpcore VERSION 0.0.1 LANGUAGES CXX CUDA)
###################################################################################################
# - build type ------------------------------------------------------------------------------------
# Set a default build type if none was specified
set(DEFAULT_BUILD_TYPE "Release")
if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
message(STATUS "Setting build type to '${DEFAULT_BUILD_TYPE}' since none specified.")
set(CMAKE_BUILD_TYPE "${DEFAULT_BUILD_TYPE}" CACHE STRING "Choose the type of build." FORCE)
# Set the possible values of build type for cmake-gui
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo")
endif ()
###################################################################################################
# Auto-detect available GPU compute architectures
set(GPU_ARCHS "" CACHE STRING "List of GPU architectures (semicolon-separated) to be compiled for. Empty string means to auto-detect the GPUs on the current system")
if ("${GPU_ARCHS}" STREQUAL "")
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/EvalGpuArchs.cmake)
evaluate_gpu_archs(GPU_ARCHS)
endif ()
###################################################################################################
# - find packages we depend on --------------------------------------------------------------------
find_package(CUDAToolkit 11.2 REQUIRED)
# package manager
include(cmake/CPM.cmake)
# macro for configuring executables
include(cmake/ConfigureExecutable.cmake)
# timers, utils, etc.
# TODO switch to default branch once merged
CPMAddPackage(
NAME helpers
URL https://gitlab.rlp.net/pararch/hpc_helpers/-/archive/restructure/hpc_helpers-restructure.zip
DOWNLOAD_EXTRACT_TIMESTAMP TRUE
)
# lightweight GPU RNG
CPMAddPackage(
NAME kiss_rng
URL https://github.com/sleeepyjack/kiss_rng/archive/refs/heads/master.zip
DOWNLOAD_EXTRACT_TIMESTAMP TRUE
)
###################################################################################################
# - warpcore target -----------------------------------------------------------------------------
add_library(warpcore INTERFACE)
target_include_directories(warpcore INTERFACE
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
$<INSTALL_INTERFACE:include>)
target_link_libraries(warpcore INTERFACE helpers kiss_rng CUDA::cudart)
###################################################################################################
# - build options ---------------------------------------------------------------------------------
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_C_COMPILER $ENV{CC})
set(CMAKE_CXX_COMPILER $ENV{CXX})
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} --expt-extended-lambda --expt-relaxed-constexpr")
set(WARPCORE_TESTS_BINARY_DIR "${CMAKE_BINARY_DIR}/tests")
set(WARPCORE_BENCHMARKS_BINARY_DIR "${CMAKE_BINARY_DIR}/benchmarks")
set(WARPCORE_EXAMPLES_BINARY_DIR "${CMAKE_BINARY_DIR}/examples")
option(WARPCORE_BUILD_TESTS "Configure CMake to build tests" OFF)
option(WARPCORE_BUILD_BENCHMARKS "Configure CMake to build benchmarks" OFF)
option(WARPCORE_BUILD_EXAMPLES "Configure CMake to build examples" OFF)
option(WARPCORE_ENABLE_INTELLISENSE "Add dummy executable to enable intellisense" OFF)
if (WARPCORE_BUILD_TESTS)
add_subdirectory(tests)
endif (WARPCORE_BUILD_TESTS)
if (WARPCORE_BUILD_BENCHMARKS)
add_subdirectory(benchmarks)
endif (WARPCORE_BUILD_BENCHMARKS)
if (WARPCORE_BUILD_EXAMPLES)
add_subdirectory(examples)
endif (WARPCORE_BUILD_EXAMPLES)
# Hack for intellisense
if(WARPCORE_ENABLE_INTELLISENSE)
add_executable(intellisense intellisense.cu)
target_link_libraries(intellisense PRIVATE warpcore)
endif(WARPCORE_ENABLE_INTELLISENSE)