-
Notifications
You must be signed in to change notification settings - Fork 8
/
CMakeLists.txt
101 lines (76 loc) · 2.62 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
cmake_minimum_required(VERSION 3.8 FATAL_ERROR)
project(bght LANGUAGES CXX CUDA)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CUDA_STANDARD 17)
set(CMAKE_CUDA_STANDARD_REQUIRED TRUE)
set(CMAKE_CXX_STANDARD_REQUIRED TRUE)
# options
option(build_benchmarks "Build benchmarks" ON)
option(build_tests "Build tests" ON)
option(build_examples "Build examples" ON)
# Direct all output to /bin directory
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/bin)
# bght flags
add_library(bght INTERFACE)
add_library(bght::bght ALIAS bght)
# CUDA and C++ compiler flags
set(CXX_FLAGS
$<IF:$<CXX_COMPILER_ID:MSVC>,
/std:c++17,
--std=c++17
>)
set(CUDA_FLAGS
$<IF:$<CXX_COMPILER_ID:MSVC>,
-Xcompiler=/std:c++17,
-Xcompiler=-std=c++17 -Wextra>
$<IF:$<CXX_COMPILER_ID:MSVC>,
-Xcompiler=/W4,
-Xcompiler=-Wall>
$<IF:$<CONFIG:Debug>,
-G -src-in-ptx,
-lineinfo>
--expt-extended-lambda
-extended-lambda
-Wno-deprecated-gpu-targets #silence deprecated architectures
--forward-unknown-to-host-linker
--forward-unknown-to-host-compiler
--expt-relaxed-constexpr
# $<$<CONFIG:Release>:-Xptxas -warn-spills -res-usage>
)
set(external_includes "${CMAKE_CURRENT_SOURCE_DIR}/external")
set(bght_includes "${CMAKE_CURRENT_SOURCE_DIR}/include")
add_library(developer_flags INTERFACE)
target_include_directories( developer_flags
INTERFACE ${external_includes})
target_compile_options(developer_flags INTERFACE
$<$<COMPILE_LANGUAGE:CXX>:${CXX_FLAGS}>
$<$<COMPILE_LANGUAGE:CUDA>:${CUDA_FLAGS}>)
target_link_libraries(bght
INTERFACE $<BUILD_INTERFACE:developer_flags>
INTERFACE $<IF:$<CXX_COMPILER_ID:MSVC>,,-lstdc++fs>)
# Visual studio setup
if(build_tests)
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
set_property(DIRECTORY PROPERTY VS_STARTUP_PROJECT test_types)
# set_property(DIRECTORY PROPERTY VS_STARTUP_PROJECT test_bcht)
# set_property(DIRECTORY PROPERTY VS_STARTUP_PROJECT exp2_BCHT)
# set_property(DIRECTORY PROPERTY VS_STARTUP_PROJECT probes_per_technique)
file(TO_NATIVE_PATH ${external_includes} external_includes_native)
file(TO_NATIVE_PATH ${bght_includes} bght_includes_native)
set(CMAKE_VS_SDK_INCLUDE_DIRECTORIES
$(VC_IncludePath)
$(WindowsSDK_IncludePath)
${external_includes_native}
${bght_includes_native}
)
endif()
add_subdirectory(include)
if(build_tests)
add_subdirectory(test)
endif(build_tests)
if(build_benchmarks)
add_subdirectory(benchmarks)
endif(build_benchmarks)
if(build_examples)
add_subdirectory(examples)
endif(build_examples)