Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion cmake-format-rapids-cmake.json
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,10 @@
},
"rapids_cpm_cccl": {
"pargs": {
"nargs": 0
"nargs": 0,
"flags": [
"ENABLE_UNSTABLE"
]
},
"kwargs": {
"BUILD_EXPORT_SET": 1,
Expand Down
23 changes: 19 additions & 4 deletions rapids-cmake/cpm/cccl.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,12 @@ file will automatically call `thrust_create_target(CCCL::Thrust FROM_OPTIONS)`.

rapids_cpm_cccl( [BUILD_EXPORT_SET <export-name>]
[INSTALL_EXPORT_SET <export-name>]
[ENABLE_UNSTABLE]
[<CPM_ARGS> ...])

``ENABLE_UNSTABLE``
Enable unstable features in CCCL.

.. |PKG_NAME| replace:: CCCL
.. include:: common_package_args.txt

Expand All @@ -49,6 +53,7 @@ Result Targets
CCCL::libcudacxx target will be created
CCCL::CUB target will be created
libcudacxx::libcudacxx target will be created
CCCL::cudax target will be created (if ENABLE_UNSTABLE is specified)

Result Variables
^^^^^^^^^^^^^^^^
Expand All @@ -62,9 +67,18 @@ Result Variables
function(rapids_cpm_cccl)
list(APPEND CMAKE_MESSAGE_CONTEXT "rapids.cpm.cccl")

set(options ENABLE_UNSTABLE)
set(one_value)
set(multi_value)
cmake_parse_arguments(_RAPIDS "${options}" "${one_value}" "${multi_value}" ${ARGN})

include("${rapids-cmake-dir}/cpm/detail/package_info.cmake")
rapids_cpm_package_info(CCCL ${ARGN} VERSION_VAR version FIND_VAR find_args CPM_VAR cpm_find_info
TO_INSTALL_VAR to_install)
rapids_cpm_package_info(CCCL ${_RAPIDS_UNPARSED_ARGUMENTS} VERSION_VAR version FIND_VAR find_args
CPM_VAR cpm_find_info TO_INSTALL_VAR to_install)

if(_RAPIDS_ENABLE_UNSTABLE)
list(APPEND cpm_find_info OPTIONS "CCCL_ENABLE_UNSTABLE ON")
endif()

if(to_install)
# Make sure we install CCCL into the `include/rapids` subdirectory instead of the default
Expand All @@ -86,8 +100,9 @@ function(rapids_cpm_cccl)
endif()

include("${rapids-cmake-dir}/cpm/find.cmake")
rapids_cpm_find(CCCL ${version} ${find_args} GLOBAL_TARGETS CCCL CCCL::CCCL CCCL::CUB
CCCL::libcudacxx
rapids_cpm_find(CCCL ${version} ${find_args}
GLOBAL_TARGETS CCCL CCCL::CCCL CCCL::CUB CCCL::libcudacxx
$<IF:$<BOOL:${_RAPIDS_ENABLE_UNSTABLE}>,CCCL::cudax,>
CPM_ARGS FIND_PACKAGE_ARGUMENTS EXACT ${cpm_find_info})

include("${rapids-cmake-dir}/cpm/detail/display_patch_status.cmake")
Expand Down
1 change: 1 addition & 0 deletions testing/cpm/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ add_cmake_build_test(cpm_bs_thread_pool-build-config-works.cmake)
add_cmake_build_test(cpm_bs_thread_pool-install-config-works.cmake)

add_cmake_config_test(cpm_cccl-simple.cmake)
add_cmake_config_test(cpm_cccl-enable-unstable.cmake)
add_cmake_config_test(cpm_cccl-export.cmake)
add_cmake_build_test(cpm_cccl-version-2-8.cmake NO_CPM_CACHE)
add_cmake_build_test(cpm_cccl-version-3-0.cmake NO_CPM_CACHE)
Expand Down
50 changes: 50 additions & 0 deletions testing/cpm/cpm_cccl-enable-unstable.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#=============================================================================
# Copyright (c) 2025, NVIDIA CORPORATION.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#=============================================================================
include(${rapids-cmake-dir}/cpm/init.cmake)
include(${rapids-cmake-dir}/cpm/cccl.cmake)

rapids_cpm_init()

# Test that CCCL::cudax does not exist before calling with ENABLE_UNSTABLE
if(TARGET CCCL::cudax)
message(FATAL_ERROR "Expected CCCL::cudax not to exist")
endif()

# Call rapids_cpm_cccl with ENABLE_UNSTABLE
rapids_cpm_cccl(ENABLE_UNSTABLE)

# Test that all expected targets exist, including CCCL::cudax
set(targets CCCL::CCCL CCCL::CUB CCCL::libcudacxx CCCL::Thrust CCCL::cudax)
foreach(target IN LISTS targets)
if(NOT TARGET ${target})
message(FATAL_ERROR "Expected ${target} to exist")
endif()
endforeach()

# Test that calling rapids_cpm_cccl(ENABLE_UNSTABLE) again is idempotent
rapids_cpm_cccl(ENABLE_UNSTABLE)

# Since rapids_cpm_cccl(ENABLE_UNSTABLE) is run already, subsequent calls to rapids_cpm_cccl()
# should also show CCCL::cudax in TARGETS. this is important when using the same EXPORT_SET for
# multiple calls to rapids_cpm_cccl(). Example: rapidsmpf requires CCCL::cudax, while also depending
# on rmm and cudf (which don't require CCCL::cudax). So, rapids_cpm_cccl() calls in rmm and cudf
# should not remove CCCL::cudax from TARGETS.
rapids_cpm_cccl()
foreach(target IN LISTS targets)
if(NOT TARGET ${target})
message(FATAL_ERROR "Expected ${target} to exist after third call")
endif()
endforeach()