-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This PR adds a new function `rapids_cpm_cccl` that adds CCCL from the new monorepo. This will eventually replace `rapids_cpm_thrust` and `rapids_cpm_libcudacxx`. Authors: - Bradley Dice (https://github.com/bdice) - Robert Maynard (https://github.com/robertmaynard) Approvers: - Robert Maynard (https://github.com/robertmaynard) URL: #495
- Loading branch information
Showing
10 changed files
with
234 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
.. cmake-module:: ../../rapids-cmake/cpm/cccl.cmake |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 <cpm_versions>` 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 <export-name>] | ||
[INSTALL_EXPORT_SET <export-name>] | ||
[<CPM_ARGS> ...]) | ||
|
||
.. |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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters