-
Notifications
You must be signed in to change notification settings - Fork 135
/
CMakeLists.txt
129 lines (106 loc) · 4.31 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
# 3.15 is the minimum for including the project with add_subdirectory.
# 3.21 is the minimum for the developer build.
cmake_minimum_required(VERSION 3.15)
project(Thrust LANGUAGES NONE)
# Determine whether Thrust is the top-level project or included into
# another project via add_subdirectory()
if ("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_LIST_DIR}")
set(THRUST_TOPLEVEL_PROJECT ON)
endif()
## thrust_fix_clang_nvcc_build_for
#
# Modifies the given target to include a fix for the clang host compiler case.
# The fix consists of force-including a header into each compilation unit.
#
function(thrust_fix_clang_nvcc_build_for target)
if (UNIX)
# Path to the header containing the fix for clang + nvcc < 11.6. For more info,
# check the content of this header.
set(clang_fix_header_path "${CMAKE_CURRENT_FUNCTION_LIST_DIR}/testing/fix_clang_nvcc_11.5.h")
# Only affects host compiler
target_compile_options(${target} PRIVATE
"$<$<COMPILE_LANGUAGE:CUDA>:-include${clang_fix_header_path}>")
endif()
endfunction()
# This must be done before any languages are enabled:
if (THRUST_TOPLEVEL_PROJECT)
cmake_minimum_required(VERSION 3.21)
endif()
# This must appear after our Compiler Hacks or else CMake will delete the cache
# and reconfigure from scratch.
# This must also appear before the installation rules, as it is required by the
# GNUInstallDirs CMake module.
enable_language(CXX)
# Optionally include installation rules for non-top-level builds:
option(THRUST_ENABLE_INSTALL_RULES "Enable installation of Thrust" ${THRUST_TOPLEVEL_PROJECT})
if (THRUST_ENABLE_INSTALL_RULES)
include(cmake/ThrustInstallRules.cmake)
endif()
# Support adding Thrust to a parent project via add_subdirectory.
# See examples/cmake/add_subdir/CMakeLists.txt for details.
if (NOT THRUST_TOPLEVEL_PROJECT)
include(cmake/ThrustAddSubdir.cmake)
return()
endif()
# We use 3.17 features when building our tests, etc.
cmake_minimum_required(VERSION 3.17)
option(THRUST_ENABLE_HEADER_TESTING "Test that all public headers compile." "ON")
option(THRUST_ENABLE_TESTING "Build Thrust testing suite." "ON")
option(THRUST_ENABLE_EXAMPLES "Build Thrust examples." "ON")
option(THRUST_ENABLE_BENCHMARKS "Build Thrust runtime benchmarks." "${CCCL_ENABLE_BENCHMARKS}")
# Allow the user to optionally select offset type dispatch to fixed 32 or 64 bit types
set(THRUST_DISPATCH_TYPE "Dynamic" CACHE STRING "Select Thrust offset type dispatch." FORCE)
set_property(CACHE THRUST_DISPATCH_TYPE PROPERTY STRINGS "Dynamic" "Force32bit" "Force64bit")
# Check if we're actually building anything before continuing. If not, no need
# to search for deps, etc. This is a common approach for packagers that just
# need the install rules. See GH issue NVIDIA/thrust#1211.
if (NOT (THRUST_ENABLE_HEADER_TESTING OR
THRUST_ENABLE_TESTING OR
THRUST_ENABLE_EXAMPLES OR
THRUST_ENABLE_BENCHMARKS))
return()
endif()
include(cmake/ThrustBuildCompilerTargets.cmake)
include(cmake/ThrustBuildTargetList.cmake)
include(cmake/ThrustFindThrust.cmake)
include(cmake/ThrustMultiConfig.cmake)
include(cmake/ThrustUtilities.cmake)
# Add cache string options for CMAKE_BUILD_TYPE and default to RelWithDebInfo.
if ("" STREQUAL "${CMAKE_BUILD_TYPE}")
set(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING "Choose the type of build." FORCE)
set_property(
CACHE CMAKE_BUILD_TYPE
PROPERTY STRINGS Debug Release RelWithDebInfo MinSizeRel
)
endif ()
# Disable compiler extensions:
set(CMAKE_CXX_EXTENSIONS OFF)
thrust_configure_multiconfig()
thrust_find_thrust()
thrust_build_compiler_targets()
thrust_update_system_found_flags()
if (THRUST_CUDA_FOUND)
include(cmake/ThrustCudaConfig.cmake)
endif()
thrust_build_target_list()
message(STATUS "CPP system found? ${THRUST_CPP_FOUND}")
message(STATUS "CUDA system found? ${THRUST_CUDA_FOUND}")
message(STATUS "TBB system found? ${THRUST_TBB_FOUND}")
message(STATUS "OMP system found? ${THRUST_OMP_FOUND}")
if (THRUST_ENABLE_HEADER_TESTING)
include(cmake/ThrustHeaderTesting.cmake)
endif()
# Both testing and examples use ctest
if (THRUST_ENABLE_TESTING OR THRUST_ENABLE_EXAMPLES)
include(CTest)
enable_testing()
endif()
if (THRUST_ENABLE_TESTING)
add_subdirectory(testing)
endif()
if (THRUST_ENABLE_EXAMPLES)
add_subdirectory(examples)
endif()
if (THRUST_ENABLE_BENCHMARKS)
add_subdirectory(benchmarks)
endif()