Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds support for pulling cuCollections using rapids-cmake #201

Merged
merged 20 commits into from
Jun 16, 2022
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
1 change: 1 addition & 0 deletions docs/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ package uses :ref:`can be found here. <cpm_versions>`
.. toctree::
:titlesonly:

/packages/rapids_cpm_cuco
/packages/rapids_cpm_gtest
/packages/rapids_cpm_libcudacxx
/packages/rapids_cpm_nvbench
Expand Down
1 change: 1 addition & 0 deletions docs/packages/rapids_cpm_cuco.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.. cmake-module:: ../../rapids-cmake/cpm/cuco.cmake
86 changes: 86 additions & 0 deletions rapids-cmake/cpm/cuco.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
#=============================================================================
# Copyright (c) 2022, 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_cuco
---------------------

.. versionadded:: v22.08.00

Allow projects to find or build `cuCollections` via `CPM` with built-in
tracking of these dependencies for correct export support.

Uses the version of cuCollections :ref:`specified in the version file <cpm_versions>` for consistency
across all RAPIDS projects.

.. code-block:: cmake

rapids_cpm_cuco( [BUILD_EXPORT_SET <export-name>]
[INSTALL_EXPORT_SET <export-name>]
)

``BUILD_EXPORT_SET``
Record that a :cmake:command:`CPMFindPackage(cuco)` call needs to occur as part of
our build directory export set.

``INSTALL_EXPORT_SET``
Record a :cmake:command:`find_dependency(cuco) <cmake:module:CMakeFindDependencyMacro>` call needs to occur as part of
our install directory export set.

vyasr marked this conversation as resolved.
Show resolved Hide resolved
Result Targets
^^^^^^^^^^^^^^
cuco::cuco target will be created

#]=======================================================================]
function(rapids_cpm_cuco)
list(APPEND CMAKE_MESSAGE_CONTEXT "rapids.cpm.cuco")

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

# Fix up _RAPIDS_UNPARSED_ARGUMENTS to have INSTALL_EXPORT_SET as this is need for rapids_cpm_find
if(_RAPIDS_INSTALL_EXPORT_SET)
list(APPEND _RAPIDS_UNPARSED_ARGUMENTS INSTALL_EXPORT_SET ${_RAPIDS_INSTALL_EXPORT_SET})
endif()

include("${rapids-cmake-dir}/cpm/detail/package_details.cmake")
rapids_cpm_package_details(cuco version repository tag shallow exclude)

set(to_exclude OFF)
if(NOT _RAPIDS_INSTALL_EXPORT_SET OR exclude)
set(to_exclude ON)
endif()

include("${rapids-cmake-dir}/cpm/find.cmake")
rapids_cpm_find(cuco ${version} ${_RAPIDS_UNPARSED_ARGUMENTS}
GLOBAL_TARGETS cuco::cuco
CPM_ARGS
GIT_REPOSITORY ${repository}
GIT_TAG ${tag}
GIT_SHALLOW ${shallow}
EXCLUDE_FROM_ALL ${to_exclude}
OPTIONS "BUILD_TESTS OFF" "BUILD_BENCHMARKS OFF" "BUILD_EXAMPLES OFF")

# Propagate up variables that CPMFindPackage provide
set(cuco_SOURCE_DIR "${cuco_SOURCE_DIR}" PARENT_SCOPE)
set(cuco_BINARY_DIR "${cuco_BINARY_DIR}" PARENT_SCOPE)
set(cuco_ADDED "${cuco_ADDED}" PARENT_SCOPE)
set(cuco_VERSION ${version} PARENT_SCOPE)

endfunction()
6 changes: 6 additions & 0 deletions rapids-cmake/cpm/versions.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@
"version" : "1.7.0",
"git_url" : "https://github.com/NVIDIA/libcudacxx.git",
"git_tag" : "${version}"
},
"cuco" : {
"version" : "0.0.1",
vyasr marked this conversation as resolved.
Show resolved Hide resolved
"git_shallow" : false,
"git_url" : "https://github.com/NVIDIA/cuCollections.git",
"git_tag" : "55029034c3f82bca36148c9be29941b37492394d"
bdice marked this conversation as resolved.
Show resolved Hide resolved
}
}
}
5 changes: 4 additions & 1 deletion testing/cpm/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#=============================================================================
# Copyright (c) 2021, NVIDIA CORPORATION.
# Copyright (c) 2021-2022, NVIDIA CORPORATION.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -59,3 +59,6 @@ add_cmake_config_test( cpm_spdlog-simple.cmake )

add_cmake_config_test( cpm_thrust-export.cmake )
add_cmake_config_test( cpm_thrust-simple.cmake )

add_cmake_config_test( cpm_cuco-simple.cmake )
add_cmake_config_test( cpm_cuco-export.cmake )
26 changes: 26 additions & 0 deletions testing/cpm/cpm_cuco-export.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#=============================================================================
# Copyright (c) 2022, 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/cuco.cmake)

rapids_cpm_init()

rapids_cpm_cuco(BUILD_EXPORT_SET test_export_set)

get_target_property(packages rapids_export_build_test_export_set PACKAGE_NAMES)
if(NOT cuco IN_LIST packages)
message(FATAL_ERROR "rapids_cpm_cuco failed to record cuco needs to be exported")
endif()
31 changes: 31 additions & 0 deletions testing/cpm/cpm_cuco-simple.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#=============================================================================
# Copyright (c) 2022, 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/cuco.cmake)

rapids_cpm_init()

if(TARGET cuco::cuco)
message(FATAL_ERROR "Expected cuco::cuco target not to exist")
endif()

rapids_cpm_cuco()
if(NOT TARGET cuco::cuco)
message(FATAL_ERROR "Expected cuco::cuco target to exist")
endif()

# Ensure that calls are idempotent.
rapids_cpm_cuco()