Skip to content

Commit 090ec5e

Browse files
committed
Include RAPIDS.cmake to WAR network issues on CI.
See also rapidsai/rmm#1886
1 parent bc8319d commit 090ec5e

File tree

2 files changed

+102
-7
lines changed

2 files changed

+102
-7
lines changed

cmake/NVBenchRapidsCMake.cmake

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

1112
include(rapids-cmake)
1213
include(rapids-cpm)

cmake/RAPIDS.cmake

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
#=============================================================================
2+
# Copyright (c) 2021-2025, NVIDIA CORPORATION.
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
#=============================================================================
16+
#
17+
# This is the preferred entry point for projects using rapids-cmake
18+
#
19+
20+
# Allow users to control which version is used
21+
if(NOT rapids-cmake-version)
22+
# Define a default version if the user doesn't set one
23+
set(rapids-cmake-version 25.04)
24+
endif()
25+
26+
# Allow users to control which GitHub repo is fetched
27+
if(NOT rapids-cmake-repo)
28+
# Define a default repo if the user doesn't set one
29+
set(rapids-cmake-repo rapidsai/rapids-cmake)
30+
endif()
31+
32+
# Allow users to control which branch is fetched
33+
if(NOT rapids-cmake-branch)
34+
# Define a default branch if the user doesn't set one
35+
set(rapids-cmake-branch "branch-${rapids-cmake-version}")
36+
endif()
37+
38+
# Allow users to control the exact URL passed to FetchContent
39+
if(NOT rapids-cmake-url)
40+
# Construct a default URL if the user doesn't set one
41+
set(rapids-cmake-url "https://github.com/${rapids-cmake-repo}/")
42+
43+
# In order of specificity
44+
if(rapids-cmake-fetch-via-git)
45+
if(rapids-cmake-sha)
46+
# An exact git SHA takes precedence over anything
47+
set(rapids-cmake-value-to-clone "${rapids-cmake-sha}")
48+
elseif(rapids-cmake-tag)
49+
# Followed by a git tag name
50+
set(rapids-cmake-value-to-clone "${rapids-cmake-tag}")
51+
else()
52+
# Or if neither of the above two were defined, use a branch
53+
set(rapids-cmake-value-to-clone "${rapids-cmake-branch}")
54+
endif()
55+
else()
56+
if(rapids-cmake-sha)
57+
# An exact git SHA takes precedence over anything
58+
set(rapids-cmake-value-to-clone "archive/${rapids-cmake-sha}.zip")
59+
elseif(rapids-cmake-tag)
60+
# Followed by a git tag name
61+
set(rapids-cmake-value-to-clone "archive/refs/tags/${rapids-cmake-tag}.zip")
62+
else()
63+
# Or if neither of the above two were defined, use a branch
64+
set(rapids-cmake-value-to-clone "archive/refs/heads/${rapids-cmake-branch}.zip")
65+
endif()
66+
endif()
67+
endif()
68+
69+
if(POLICY CMP0135)
70+
cmake_policy(PUSH)
71+
cmake_policy(SET CMP0135 NEW)
72+
endif()
73+
include(FetchContent)
74+
if(rapids-cmake-fetch-via-git)
75+
FetchContent_Declare(rapids-cmake
76+
GIT_REPOSITORY "${rapids-cmake-url}"
77+
GIT_TAG "${rapids-cmake-value-to-clone}")
78+
else()
79+
string(APPEND rapids-cmake-url "${rapids-cmake-value-to-clone}")
80+
FetchContent_Declare(rapids-cmake URL "${rapids-cmake-url}")
81+
endif()
82+
if(POLICY CMP0135)
83+
cmake_policy(POP)
84+
endif()
85+
FetchContent_GetProperties(rapids-cmake)
86+
if(rapids-cmake_POPULATED)
87+
# Something else has already populated rapids-cmake, only thing
88+
# we need to do is setup the CMAKE_MODULE_PATH
89+
if(NOT "${rapids-cmake-dir}" IN_LIST CMAKE_MODULE_PATH)
90+
list(APPEND CMAKE_MODULE_PATH "${rapids-cmake-dir}")
91+
endif()
92+
else()
93+
FetchContent_MakeAvailable(rapids-cmake)
94+
endif()

0 commit comments

Comments
 (0)