Skip to content

Commit

Permalink
Manually invoke install rules for components (#505)
Browse files Browse the repository at this point in the history
CCCL's CMake is currently set up to exit early whenever it's added via `add_subdirectory`, which inadvertently prevents the install rules of its components (Thrust/CUB/libcudacxx) from being called. We don't currently have a way to tell CCCL not to do this because preventing that early exit leads to other undesirable outcomes (such as the CCCL::CCCL targets not being created correctly). Therefore, to work around this we must include the various install rule modules directly until this can be fixed upstream in CCCL.

In addition, we require a couple of patches to CCCL's CMake so that 1) the correct config files are installed, and 2) so that multiple invocations of `find_package(CCCL)` will work. These patches have already been fixed on the latest CCCL, see NVIDIA/cccl#298 and NVIDIA/cccl#1157.

Authors:
  - Vyas Ramasubramani (https://github.com/vyasr)

Approvers:
  - Bradley Dice (https://github.com/bdice)

URL: #505
  • Loading branch information
vyasr authored Dec 14, 2023
1 parent c99b5c9 commit c7de042
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 1 deletion.
24 changes: 24 additions & 0 deletions rapids-cmake/cpm/cccl.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,30 @@ function(rapids_cpm_cccl)
EXCLUDE_FROM_ALL ${exclude}
OPTIONS "CCCL_ENABLE_INSTALL_RULES ${to_install}")

if(to_install)
# CCCL does not currently correctly support installation of cub/thrust/libcudacxx. The only
# option that makes this work is to manually invoke the install rules until CCCL's CMake is
# fixed.
set(Thrust_SOURCE_DIR "${CCCL_SOURCE_DIR}/thrust")
set(CUB_SOURCE_DIR "${CCCL_SOURCE_DIR}/cub")
set(libcudacxx_SOURCE_DIR "${CCCL_SOURCE_DIR}/libcudacxx")

set(Thrust_BINARY_DIR "${CCCL_BINARY_DIR}")
set(CUB_BINARY_DIR "${CCCL_BINARY_DIR}")
set(libcudacxx_BINARY_DIR "${CCCL_BINARY_DIR}")

set(Thrust_ENABLE_INSTALL_RULES ON)
set(CUB_ENABLE_INSTALL_RULES ON)
set(libcudacxx_ENABLE_INSTALL_RULES ON)

include("${Thrust_SOURCE_DIR}/cmake/ThrustInstallRules.cmake")
include("${CUB_SOURCE_DIR}/cmake/CubInstallRules.cmake")

# libcudacxx's install rules require inserting an extra level of nesting for the include dir.
set(CMAKE_INSTALL_INCLUDEDIR "${CMAKE_INSTALL_INCLUDEDIR}/libcudacxx")
include("${libcudacxx_SOURCE_DIR}/cmake/libcudacxxInstallRules.cmake")
endif()

include("${rapids-cmake-dir}/cpm/detail/display_patch_status.cmake")
rapids_cpm_display_patch_status(CCCL)

Expand Down
52 changes: 52 additions & 0 deletions rapids-cmake/cpm/patches/cccl/bug_fixes.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
diff --git a/cub/cmake/CubInstallRules.cmake b/cub/cmake/CubInstallRules.cmake
index d26da438e..a8b3b1940 100644
--- a/cub/cmake/CubInstallRules.cmake
+++ b/cub/cmake/CubInstallRules.cmake
@@ -12,7 +12,7 @@ install(DIRECTORY "${CUB_SOURCE_DIR}/cub"

install(DIRECTORY "${CUB_SOURCE_DIR}/cub/cmake/"
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/cub"
- PATTERN *.cmake.in EXCLUDE
+ REGEX "(.*-header-search\.cmake|.*\.cmake\.in)" EXCLUDE
)
# Need to configure a file to store the infix specified in
# CMAKE_INSTALL_INCLUDEDIR since it can be defined by the user
diff --git a/lib/cmake/cccl/cccl-config.cmake b/lib/cmake/cccl/cccl-config.cmake
index 9baebb1b5..d9eeeba50 100644
--- a/lib/cmake/cccl/cccl-config.cmake
+++ b/lib/cmake/cccl/cccl-config.cmake
@@ -71,7 +71,7 @@ foreach(component IN LISTS components)
"${cccl_cmake_dir}/.." # Install layout
)

- if (TARGET Thrust::Thrust AND NOT CCCL::Thrust)
+ if (TARGET Thrust::Thrust AND NOT TARGET CCCL::Thrust)
# By default, configure a CCCL::Thrust target with host=cpp device=cuda
option(CCCL_ENABLE_DEFAULT_THRUST_TARGET
"Create a CCCL::Thrust target using CCCL_THRUST_[HOST|DEVICE]_SYSTEM."
diff --git a/libcudacxx/cmake/libcudacxxInstallRules.cmake b/libcudacxx/cmake/libcudacxxInstallRules.cmake
index f99a5606f..1c1ed5cb0 100644
--- a/libcudacxx/cmake/libcudacxxInstallRules.cmake
+++ b/libcudacxx/cmake/libcudacxxInstallRules.cmake
@@ -22,7 +22,7 @@ install(DIRECTORY "${libcudacxx_SOURCE_DIR}/include/nv"
# Libcudacxx cmake package
install(DIRECTORY "${libcudacxx_SOURCE_DIR}/lib/cmake/libcudacxx"
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake"
- PATTERN *.cmake.in EXCLUDE
+ REGEX "(.*-header-search\.cmake|.*\.cmake\.in)" EXCLUDE
)

# Need to configure a file to store CMAKE_INSTALL_INCLUDEDIR
diff --git a/thrust/cmake/ThrustInstallRules.cmake b/thrust/cmake/ThrustInstallRules.cmake
index 0898d3964..54b40e515 100644
--- a/thrust/cmake/ThrustInstallRules.cmake
+++ b/thrust/cmake/ThrustInstallRules.cmake
@@ -13,7 +13,7 @@ install(DIRECTORY "${Thrust_SOURCE_DIR}/thrust"

install(DIRECTORY "${Thrust_SOURCE_DIR}/thrust/cmake/"
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/thrust"
- PATTERN *.cmake.in EXCLUDE
+ REGEX "(.*-header-search\.cmake|.*\.cmake\.in)" EXCLUDE
)
# Need to configure a file to store the infix specified in
# CMAKE_INSTALL_INCLUDEDIR since it can be defined by the user
9 changes: 8 additions & 1 deletion rapids-cmake/cpm/versions.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,14 @@
"CCCL" : {
"version" : "2.2.0",
"git_url" : "https://github.com/NVIDIA/cccl.git",
"git_tag" : "v${version}"
"git_tag" : "v${version}",
"patches" : [
{
"file" : "cccl/bug_fixes.diff",
"issue" : "CCCL installs header-search.cmake files in nondeterministic order and has a typo in checking target creation that leads to duplicates",
"fixed_in" : "2.3"
}
]
},
"cuco" : {
"version" : "0.0.1",
Expand Down

0 comments on commit c7de042

Please sign in to comment.