diff --git a/cmake-format-rapids-cmake.json b/cmake-format-rapids-cmake.json index 0590a6ff..6525d287 100644 --- a/cmake-format-rapids-cmake.json +++ b/cmake-format-rapids-cmake.json @@ -88,6 +88,15 @@ } }, + "rapids_cpm_cccl": { + "pargs": { + "nargs": 0 + }, + "kwargs": { + "BUILD_EXPORT_SET": 1, + "INSTALL_EXPORT_SET": 1 + } + }, "rapids_cpm_cuco": { "pargs": { "nargs": 0 diff --git a/conda/recipes/rapids_core_dependencies/CMakeLists.txt b/conda/recipes/rapids_core_dependencies/CMakeLists.txt index 8a00aa47..6cd31ec1 100644 --- a/conda/recipes/rapids_core_dependencies/CMakeLists.txt +++ b/conda/recipes/rapids_core_dependencies/CMakeLists.txt @@ -1,5 +1,5 @@ #============================================================================= -# Copyright (c) 2022, NVIDIA CORPORATION. +# Copyright (c) 2022-2023, NVIDIA CORPORATION. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -23,8 +23,6 @@ include(${rapids-cmake-dir}/cpm/init.cmake) rapids_cpm_init() # Download all source packages -include(${rapids-cmake-dir}/cpm/libcudacxx.cmake) -include(${rapids-cmake-dir}/cpm/thrust.cmake) +include(${rapids-cmake-dir}/cpm/cccl.cmake) set(CPM_DOWNLOAD_ALL "ON") -rapids_cpm_libcudacxx(INSTALL_EXPORT_SET rapids-dependencies) -rapids_cpm_thrust(NAMESPACE temp INSTALL_EXPORT_SET rapids-dependencies) +rapids_cpm_cccl(NAMESPACE temp INSTALL_EXPORT_SET rapids-dependencies) diff --git a/docs/api.rst b/docs/api.rst index a2779df6..7d4ce5b2 100644 --- a/docs/api.rst +++ b/docs/api.rst @@ -48,6 +48,7 @@ package uses :ref:`can be found here. ` .. toctree:: :titlesonly: + /packages/rapids_cpm_cccl /packages/rapids_cpm_cuco /packages/rapids_cpm_fmt /packages/rapids_cpm_gbench diff --git a/docs/packages/rapids_cpm_cccl.rst b/docs/packages/rapids_cpm_cccl.rst new file mode 100644 index 00000000..8795d64a --- /dev/null +++ b/docs/packages/rapids_cpm_cccl.rst @@ -0,0 +1 @@ +.. cmake-module:: ../../rapids-cmake/cpm/cccl.cmake diff --git a/rapids-cmake/cpm/cccl.cmake b/rapids-cmake/cpm/cccl.cmake new file mode 100644 index 00000000..3837a40e --- /dev/null +++ b/rapids-cmake/cpm/cccl.cmake @@ -0,0 +1,119 @@ +#============================================================================= +# Copyright (c) 2023, 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_guard(GLOBAL) + +#[=======================================================================[.rst: +rapids_cpm_cccl +--------------- + +.. versionadded:: v24.02.00 + +Allow projects to find or build `CCCL` via `CPM` with built-in +tracking of these dependencies for correct export support. + +Uses the version of CCCL :ref:`specified in the version file ` for consistency +across all RAPIDS projects. + +When `BUILD_EXPORT_SET` is specified the generated build export set dependency +file will automatically call `thrust_create_target(CCCL::Thrust FROM_OPTIONS)`. + +When `INSTALL_EXPORT_SET` is specified the generated install export set dependency +file will automatically call `thrust_create_target(CCCL::Thrust FROM_OPTIONS)`. + +.. code-block:: cmake + + rapids_cpm_cccl( [BUILD_EXPORT_SET ] + [INSTALL_EXPORT_SET ] + [ ...]) + +.. |PKG_NAME| replace:: CCCL +.. include:: common_package_args.txt + +Result Targets +^^^^^^^^^^^^^^ + CCCL::CCCL target will be created + CCCL::Thrust target will be created + CCCL::libcudacxx target will be created + CCCL::CUB target will be created + libcudacxx::libcudacxx target will be created + +Result Variables +^^^^^^^^^^^^^^^^ + :cmake:variable:`CCCL_SOURCE_DIR` is set to the path to the source directory of CCCL. + :cmake:variable:`CCCL_BINARY_DIR` is set to the path to the build directory of CCCL. + :cmake:variable:`CCCL_ADDED` is set to a true value if CCCL has not been added before. + :cmake:variable:`CCCL_VERSION` is set to the version of CCCL specified by the versions.json. + +#]=======================================================================] +# cmake-lint: disable=R0915 +function(rapids_cpm_cccl) + list(APPEND CMAKE_MESSAGE_CONTEXT "rapids.cpm.cccl") + + include("${rapids-cmake-dir}/cpm/detail/package_details.cmake") + rapids_cpm_package_details(CCCL version repository tag shallow exclude) + + set(to_install OFF) + if(INSTALL_EXPORT_SET IN_LIST ARGN AND NOT exclude) + set(to_install ON) + # Make sure we install CCCL into the `include/rapids` subdirectory instead of the default + include(GNUInstallDirs) + set(CMAKE_INSTALL_INCLUDEDIR "${CMAKE_INSTALL_INCLUDEDIR}/rapids") + set(CMAKE_INSTALL_LIBDIR "${CMAKE_INSTALL_LIBDIR}/rapids") + endif() + + include("${rapids-cmake-dir}/cpm/detail/generate_patch_command.cmake") + rapids_cpm_generate_patch_command(CCCL ${version} patch_command) + + # Ensure for CMake 3.24+ that the CCCL::Thrust target exists: + # https://github.com/NVIDIA/cccl/pull/1182 + set(CMAKE_FIND_PACKAGE_TARGETS_GLOBAL ON) + + include("${rapids-cmake-dir}/cpm/find.cmake") + rapids_cpm_find(CCCL ${version} ${ARGN} + GLOBAL_TARGETS CCCL CCCL::CCCL CCCL::Thrust CCCL::CUB CCCL::libcudacxx + CPM_ARGS FIND_PACKAGE_ARGUMENTS EXACT + GIT_REPOSITORY ${repository} + GIT_TAG ${tag} + GIT_SHALLOW ${shallow} + PATCH_COMMAND ${patch_command} + EXCLUDE_FROM_ALL ${exclude} + OPTIONS "CCCL_ENABLE_INSTALL_RULES ${to_install}") + + include("${rapids-cmake-dir}/cpm/detail/display_patch_status.cmake") + rapids_cpm_display_patch_status(CCCL) + + set(options) + set(one_value BUILD_EXPORT_SET INSTALL_EXPORT_SET) + set(multi_value) + cmake_parse_arguments(_RAPIDS "${options}" "${one_value}" "${multi_value}" ${ARGN}) + + if(CCCL_SOURCE_DIR) + # Store where CMake can find the Thrust-config.cmake that comes part of Thrust source code + include("${rapids-cmake-dir}/export/find_package_root.cmake") + rapids_export_find_package_root(BUILD CCCL "${CCCL_SOURCE_DIR}/cmake" + EXPORT_SET ${_RAPIDS_BUILD_EXPORT_SET}) + rapids_export_find_package_root(INSTALL CCCL + [=[${CMAKE_CURRENT_LIST_DIR}/../../rapids/cmake/cccl]=] + EXPORT_SET ${_RAPIDS_INSTALL_EXPORT_SET} CONDITION to_install) + endif() + + # Propagate up variables that CPMFindPackage provides + set(CCCL_SOURCE_DIR "${CCCL_SOURCE_DIR}" PARENT_SCOPE) + set(CCCL_BINARY_DIR "${CCCL_BINARY_DIR}" PARENT_SCOPE) + set(CCCL_ADDED "${CCCL_ADDED}" PARENT_SCOPE) + set(CCCL_VERSION ${version} PARENT_SCOPE) + +endfunction() diff --git a/rapids-cmake/cpm/versions.json b/rapids-cmake/cpm/versions.json index bd97b0a7..500bf497 100644 --- a/rapids-cmake/cpm/versions.json +++ b/rapids-cmake/cpm/versions.json @@ -5,6 +5,11 @@ "git_url" : "https://github.com/google/benchmark.git", "git_tag" : "v${version}" }, + "CCCL" : { + "version" : "2.2.0", + "git_url" : "https://github.com/NVIDIA/cccl.git", + "git_tag" : "v${version}" + }, "cuco" : { "version" : "0.0.1", "git_shallow" : false, @@ -73,11 +78,11 @@ "git_url" : "https://github.com/gabime/spdlog.git", "git_tag" : "v${version}", "patches" : [ - { - "file" : "spdlog/nvcc_constexpr_fix.diff", - "issue" : "Fix constexpr mismatch between spdlog and fmt [https://github.com/gabime/spdlog/issues/2856]", - "fixed_in" : "1.13" - } + { + "file" : "spdlog/nvcc_constexpr_fix.diff", + "issue" : "Fix constexpr mismatch between spdlog and fmt [https://github.com/gabime/spdlog/issues/2856]", + "fixed_in" : "1.13" + } ] }, "Thrust" : { diff --git a/testing/cpm/CMakeLists.txt b/testing/cpm/CMakeLists.txt index 13adf187..edc1d73e 100644 --- a/testing/cpm/CMakeLists.txt +++ b/testing/cpm/CMakeLists.txt @@ -43,6 +43,9 @@ add_cmake_config_test( cpm_generate_patch_command-invalid.cmake ) add_cmake_config_test( cpm_generate_patch_command-override.cmake ) add_cmake_config_test( cpm_generate_patch_command-current_json_dir.cmake ) +add_cmake_config_test( cpm_cccl-simple.cmake ) +add_cmake_config_test( cpm_cccl-export.cmake ) + add_cmake_config_test( cpm_cuco-simple.cmake ) add_cmake_config_test( cpm_cuco-export.cmake ) add_cmake_config_test( cpm_cuco-libcudacxx-no-install-export.cmake ) diff --git a/testing/cpm/cpm_cccl-export.cmake b/testing/cpm/cpm_cccl-export.cmake new file mode 100644 index 00000000..8410a5be --- /dev/null +++ b/testing/cpm/cpm_cccl-export.cmake @@ -0,0 +1,32 @@ +#============================================================================= +# Copyright (c) 2023, 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() + +rapids_cpm_cccl(BUILD_EXPORT_SET test) +rapids_cpm_cccl(INSTALL_EXPORT_SET test2) + +get_target_property(packages rapids_export_build_test PACKAGE_NAMES) +if(NOT CCCL IN_LIST packages) + message(FATAL_ERROR "rapids_cpm_cccl failed to record CCCL needs to be exported") +endif() + +get_target_property(packages rapids_export_install_test2 PACKAGE_NAMES) +if(NOT CCCL IN_LIST packages) + message(FATAL_ERROR "rapids_cpm_cccl failed to record CCCL needs to be exported") +endif() diff --git a/testing/cpm/cpm_cccl-simple.cmake b/testing/cpm/cpm_cccl-simple.cmake new file mode 100644 index 00000000..fac8c1b8 --- /dev/null +++ b/testing/cpm/cpm_cccl-simple.cmake @@ -0,0 +1,54 @@ +#============================================================================= +# Copyright (c) 2023, 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() + +if(TARGET CCCL::CCCL) + message(FATAL_ERROR "Expected CCCL::CUB not to exist") +endif() +if(TARGET CCCL::CUB) + message(FATAL_ERROR "Expected CCCL::CUB not to exist") +endif() +if(TARGET CCCL::libcudacxx) + message(FATAL_ERROR "Expected CCCL::libcudacxx not to exist") +endif() +if(TARGET CCCL::Thrust) + message(FATAL_ERROR "Expected CCCL::Thrust not to exist") +endif() +if(TARGET libcudacxx::libcudacxx) + message(FATAL_ERROR "Expected libcudacxx::libcudacxx not to exist") +endif() + +rapids_cpm_cccl() +if(NOT TARGET CCCL::CCCL) + message(FATAL_ERROR "Expected CCCL::CUB target to exist") +endif() +if(NOT TARGET CCCL::CUB) + message(FATAL_ERROR "Expected CCCL::CUB target to exist") +endif() +if(NOT TARGET CCCL::libcudacxx) + message(FATAL_ERROR "Expected CCCL::libcudacxx target to exist") +endif() +if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.24.0 AND NOT TARGET CCCL::Thrust) + message(FATAL_ERROR "Expected CCCL::Thrust target to exist") +endif() +if(NOT TARGET libcudacxx::libcudacxx) + message(FATAL_ERROR "Expected libcudacxx::libcudacxx target to exist") +endif() + +rapids_cpm_cccl() diff --git a/testing/utils/fill_cache/CMakeLists.txt b/testing/utils/fill_cache/CMakeLists.txt index 0dc8bcc6..15cdf72e 100644 --- a/testing/utils/fill_cache/CMakeLists.txt +++ b/testing/utils/fill_cache/CMakeLists.txt @@ -19,6 +19,7 @@ project(fill_cache LANGUAGES CXX) include(${rapids-cmake-dir}/cpm/init.cmake) +include(${rapids-cmake-dir}/cpm/cccl.cmake) include(${rapids-cmake-dir}/cpm/cuco.cmake) include(${rapids-cmake-dir}/cpm/gbench.cmake) include(${rapids-cmake-dir}/cpm/gtest.cmake) @@ -36,6 +37,7 @@ set(CPM_SOURCE_CACHE "${CMAKE_BINARY_DIR}") # Download all source packages set(CPM_DOWNLOAD_ALL "ON") +rapids_cpm_cccl(DOWNLOAD_ONLY ON) rapids_cpm_cuco(DOWNLOAD_ONLY ON) rapids_cpm_gbench(DOWNLOAD_ONLY ON) rapids_cpm_gtest(DOWNLOAD_ONLY ON)