Skip to content

Commit e13ce6e

Browse files
committed
Update thrust to 1.17 and simplify logic due to upstream CMake improvements
1 parent 9c9f0dd commit e13ce6e

File tree

2 files changed

+21
-73
lines changed

2 files changed

+21
-73
lines changed

rapids-cmake/cpm/thrust.cmake

Lines changed: 19 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -55,21 +55,38 @@ Result Variables
5555
function(rapids_cpm_thrust NAMESPACE namespaces_name)
5656
list(APPEND CMAKE_MESSAGE_CONTEXT "rapids.cpm.thrust")
5757

58+
set(options)
59+
set(one_value BUILD_EXPORT_SET INSTALL_EXPORT_SET)
60+
set(multi_value)
61+
cmake_parse_arguments(_RAPIDS "${options}" "${one_value}" "${multi_value}" ${ARGN})
62+
63+
set(enable_install OFF)
64+
if(_RAPIDS_INSTALL_EXPORT_SET)
65+
set(enable_install ON)
66+
# Make sure we install thrust into the `include/rapids` subdirectory instead of the default
67+
include(GNUInstallDirs)
68+
set(CMAKE_INSTALL_INCLUDEDIR "${CMAKE_INSTALL_INCLUDEDIR}/rapids")
69+
endif()
70+
5871
include("${rapids-cmake-dir}/cpm/detail/package_details.cmake")
5972
rapids_cpm_package_details(Thrust version repository tag shallow exclude)
6073

6174
include("${rapids-cmake-dir}/cpm/find.cmake")
62-
rapids_cpm_find(Thrust ${version} ${ARGN}
75+
rapids_cpm_find(Thrust ${version} ${_RAPIDS_UNPARSED_ARGUMENTS}
6376
GLOBAL_TARGETS ${namespaces_name}::Thrust
6477
CPM_ARGS FIND_PACKAGE_ARGUMENTS EXACT
6578
GIT_REPOSITORY ${repository}
6679
GIT_TAG ${tag}
6780
GIT_SHALLOW ${shallow}
6881
EXCLUDE_FROM_ALL ${exclude}
69-
OPTIONS "THRUST_ENABLE_INSTALL_RULES OFF")
82+
OPTIONS "THRUST_ENABLE_INSTALL_RULES ${enable_install}")
7083

7184
if(NOT TARGET ${namespaces_name}::Thrust)
7285
thrust_create_target(${namespaces_name}::Thrust FROM_OPTIONS)
86+
set_target_properties(${namespaces_name}::Thrust PROPERTIES IMPORTED_NO_SYSTEM ON)
87+
if(TARGET _Thrust_Thrust)
88+
set_target_properties(_Thrust_Thrust PROPERTIES IMPORTED_NO_SYSTEM ON)
89+
endif()
7390
endif()
7491

7592
# Since `GLOBAL_TARGET ${namespaces_name}::Thrust` will list the target to be promoted to global
@@ -78,11 +95,6 @@ function(rapids_cpm_thrust NAMESPACE namespaces_name)
7895
#
7996
# So determine what `BUILD_EXPORT_SET` and `INSTALL_EXPORT_SET` this was added to and remove
8097
# ${namespaces_name}::Thrust
81-
set(options CPM_ARGS)
82-
set(one_value BUILD_EXPORT_SET INSTALL_EXPORT_SET)
83-
set(multi_value)
84-
cmake_parse_arguments(_RAPIDS "${options}" "${one_value}" "${multi_value}" ${ARGN})
85-
8698
if(_RAPIDS_BUILD_EXPORT_SET)
8799
set(target_name rapids_export_build_${_RAPIDS_BUILD_EXPORT_SET})
88100
get_target_property(global_targets ${target_name} GLOBAL_TARGETS)
@@ -97,70 +109,6 @@ function(rapids_cpm_thrust NAMESPACE namespaces_name)
97109
set_target_properties(${target_name} PROPERTIES GLOBAL_TARGETS "${global_targets}")
98110
endif()
99111

100-
# only install thrust when we have an in-source version
101-
if(Thrust_SOURCE_DIR AND _RAPIDS_INSTALL_EXPORT_SET AND NOT exclude)
102-
#[==[
103-
Projects such as cudf, and rmm require a newer versions of thrust than can be found in the oldest supported CUDA toolkit.
104-
This requires these components to install/packaged so that consumers use the same version. To make sure that the custom
105-
version of thrust is used over the CUDA toolkit version we need to ensure we always use an user include and not a system.
106-
107-
By default if we allow thrust to install into `CMAKE_INSTALL_INCLUDEDIR` alongside rmm (or other pacakges)
108-
we will get a install tree that looks like this:
109-
110-
install/include/rmm
111-
install/include/cub
112-
install/include/thrust
113-
114-
This is a problem for CMake+NVCC due to the rules around import targets, and user/system includes. In this case both
115-
rmm and thrust will specify an include path of `install/include`, while thrust tries to mark it as an user include,
116-
since rmm uses CMake's default of system include. Compilers when provided the same include as both user and system
117-
always goes with system.
118-
119-
Now while rmm could also mark `install/include` as system this just pushes the issue to another dependency which
120-
isn't built by RAPIDS and comes by and marks `install/include` as system.
121-
122-
Instead the more reliable option is to make sure that we get thrust to be placed in an unique include path that
123-
to other project will use. In the case of rapids-cmake we install the headers to `include/rapids/thrust`
124-
#]==]
125-
include(GNUInstallDirs)
126-
install(DIRECTORY "${Thrust_SOURCE_DIR}/thrust"
127-
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/rapids/thrust/" FILES_MATCHING
128-
REGEX "\\.(h|inl)$")
129-
install(DIRECTORY "${Thrust_SOURCE_DIR}/dependencies/cub/cub"
130-
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/rapids/thrust/dependencies/" FILES_MATCHING
131-
PATTERN "*.cuh")
132-
133-
install(DIRECTORY "${Thrust_SOURCE_DIR}/thrust/cmake"
134-
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/rapids/thrust/thrust/")
135-
install(DIRECTORY "${Thrust_SOURCE_DIR}/dependencies/cub/cub/cmake"
136-
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/rapids/thrust/dependencies/cub/")
137-
138-
include("${rapids-cmake-dir}/cmake/install_lib_dir.cmake")
139-
rapids_cmake_install_lib_dir(install_location) # Use the correct conda aware path
140-
141-
# We need to install the forwarders in `lib/cmake/thrust` and `lib/cmake/cub`
142-
set(scratch_dir
143-
"${CMAKE_BINARY_DIR}/rapids-cmake/${_RAPIDS_INSTALL_EXPORT_SET}/install/scratch/")
144-
145-
file(WRITE "${scratch_dir}/thrust-config.cmake"
146-
[=[include("${CMAKE_CURRENT_LIST_DIR}/../../../include/rapids/thrust/thrust/cmake/thrust-config.cmake")]=]
147-
)
148-
file(WRITE "${scratch_dir}/thrust-config-version.cmake"
149-
[=[include("${CMAKE_CURRENT_LIST_DIR}/../../../include/rapids/thrust/thrust/cmake/thrust-config-version.cmake")]=]
150-
)
151-
install(FILES "${scratch_dir}/thrust-config.cmake" "${scratch_dir}/thrust-config-version.cmake"
152-
DESTINATION "${install_location}/cmake/thrust")
153-
154-
file(WRITE "${scratch_dir}/cub-config.cmake"
155-
[=[include("${CMAKE_CURRENT_LIST_DIR}/../../../include/rapids/thrust/dependencies/cub/cub-config.cmake")]=]
156-
)
157-
file(WRITE "${scratch_dir}/cub-config-version.cmake"
158-
[=[include("${CMAKE_CURRENT_LIST_DIR}/../../../include/rapids/thrust/dependencies/cub/cub-config-version.cmake")]=]
159-
)
160-
install(FILES "${scratch_dir}/cub-config.cmake" "${scratch_dir}/cub-config-version.cmake"
161-
DESTINATION "${install_location}/cmake/cub")
162-
endif()
163-
164112
# Propagate up variables that CPMFindPackage provide
165113
set(Thrust_SOURCE_DIR "${Thrust_SOURCE_DIR}" PARENT_SCOPE)
166114
set(Thrust_BINARY_DIR "${Thrust_BINARY_DIR}" PARENT_SCOPE)

rapids-cmake/cpm/versions.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@
3131
"git_tag" : "v${version}"
3232
},
3333
"Thrust" : {
34-
"version" : "1.15.0.0",
34+
"version" : "1.16.0",
3535
"git_url" : "https://github.com/NVIDIA/thrust.git",
36-
"git_tag" : "1.15.0"
36+
"git_tag" : "${version}"
3737
},
3838
"libcudacxx" : {
3939
"version" : "1.7.0",

0 commit comments

Comments
 (0)