Include RAPIDS.cmake to WAR network issues on CI. (#236)

See also https://github.com/rapidsai/rmm/pull/1886
This commit is contained in:
Allison Piper
2025-06-24 17:03:30 -04:00
committed by GitHub
parent bc8319d5d9
commit 8e3e0ad117
2 changed files with 102 additions and 7 deletions

View File

@@ -1,12 +1,13 @@
# Called before project(...)
macro(nvbench_load_rapids_cmake)
if(NOT EXISTS "${CMAKE_CURRENT_BINARY_DIR}/NVBENCH_RAPIDS.cmake")
file(DOWNLOAD
https://raw.githubusercontent.com/rapidsai/rapids-cmake/branch-25.04/RAPIDS.cmake
"${CMAKE_CURRENT_BINARY_DIR}/NVBENCH_RAPIDS.cmake"
)
endif()
include("${CMAKE_CURRENT_BINARY_DIR}/NVBENCH_RAPIDS.cmake")
# - Including directly, see https://github.com/rapidsai/rmm/pull/1886
# - Versioned download URL:
# https://raw.githubusercontent.com/rapidsai/rapids-cmake/branch-XX.YY/RAPIDS.cmake
# - This macro is always called before project() in the root CMakeLists.txt, so:
# - we can't just use NVBench_SOURCE_DIR, it's not defined yet.
# - We can't rely on CMAKE_CURRENT_LIST_DIR because of macro expansion.
# - We can fallback to CURRENT_SOURCE_DIR because we know this will be expanded in the root:
include("${CMAKE_CURRENT_SOURCE_DIR}/cmake/RAPIDS.cmake")
include(rapids-cmake)
include(rapids-cpm)

94
cmake/RAPIDS.cmake Normal file
View File

@@ -0,0 +1,94 @@
#=============================================================================
# Copyright (c) 2021-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.
#=============================================================================
#
# This is the preferred entry point for projects using rapids-cmake
#
# Allow users to control which version is used
if(NOT rapids-cmake-version)
# Define a default version if the user doesn't set one
set(rapids-cmake-version 25.04)
endif()
# Allow users to control which GitHub repo is fetched
if(NOT rapids-cmake-repo)
# Define a default repo if the user doesn't set one
set(rapids-cmake-repo rapidsai/rapids-cmake)
endif()
# Allow users to control which branch is fetched
if(NOT rapids-cmake-branch)
# Define a default branch if the user doesn't set one
set(rapids-cmake-branch "branch-${rapids-cmake-version}")
endif()
# Allow users to control the exact URL passed to FetchContent
if(NOT rapids-cmake-url)
# Construct a default URL if the user doesn't set one
set(rapids-cmake-url "https://github.com/${rapids-cmake-repo}/")
# In order of specificity
if(rapids-cmake-fetch-via-git)
if(rapids-cmake-sha)
# An exact git SHA takes precedence over anything
set(rapids-cmake-value-to-clone "${rapids-cmake-sha}")
elseif(rapids-cmake-tag)
# Followed by a git tag name
set(rapids-cmake-value-to-clone "${rapids-cmake-tag}")
else()
# Or if neither of the above two were defined, use a branch
set(rapids-cmake-value-to-clone "${rapids-cmake-branch}")
endif()
else()
if(rapids-cmake-sha)
# An exact git SHA takes precedence over anything
set(rapids-cmake-value-to-clone "archive/${rapids-cmake-sha}.zip")
elseif(rapids-cmake-tag)
# Followed by a git tag name
set(rapids-cmake-value-to-clone "archive/refs/tags/${rapids-cmake-tag}.zip")
else()
# Or if neither of the above two were defined, use a branch
set(rapids-cmake-value-to-clone "archive/refs/heads/${rapids-cmake-branch}.zip")
endif()
endif()
endif()
if(POLICY CMP0135)
cmake_policy(PUSH)
cmake_policy(SET CMP0135 NEW)
endif()
include(FetchContent)
if(rapids-cmake-fetch-via-git)
FetchContent_Declare(rapids-cmake
GIT_REPOSITORY "${rapids-cmake-url}"
GIT_TAG "${rapids-cmake-value-to-clone}")
else()
string(APPEND rapids-cmake-url "${rapids-cmake-value-to-clone}")
FetchContent_Declare(rapids-cmake URL "${rapids-cmake-url}")
endif()
if(POLICY CMP0135)
cmake_policy(POP)
endif()
FetchContent_GetProperties(rapids-cmake)
if(rapids-cmake_POPULATED)
# Something else has already populated rapids-cmake, only thing
# we need to do is setup the CMAKE_MODULE_PATH
if(NOT "${rapids-cmake-dir}" IN_LIST CMAKE_MODULE_PATH)
list(APPEND CMAKE_MODULE_PATH "${rapids-cmake-dir}")
endif()
else()
FetchContent_MakeAvailable(rapids-cmake)
endif()