Skip to content

Commit 73e5131

Browse files
bdiceMathisHammel
authored andcommitted
Vendor RAPIDS.cmake (rapidsai#5024)
This works around a problem where GitHub is rejecting requests to the `githubusercontent.com` CDN. We vendor the contents of `RAPIDS.cmake` from `rapidsai/rapids-cmake` to avoid a network call. xref: rapidsai/rapids-cmake#809 xref: https://github.com/rapidsai/build-infra/issues/206 Authors: - Bradley Dice (https://github.com/bdice) Approvers: - Peter Andreas Entschev (https://github.com/pentschev) - Kyle Edwards (https://github.com/KyleFromNVIDIA) URL: rapidsai#5024
1 parent abba481 commit 73e5131

File tree

8 files changed

+100
-16
lines changed

8 files changed

+100
-16
lines changed

cmake/RAPIDS.cmake

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

rapids_config.cmake renamed to cmake/rapids_config.cmake

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# =============================================================================
2-
# Copyright (c) 2018-2024, NVIDIA CORPORATION.
2+
# Copyright (c) 2018-2025, NVIDIA CORPORATION.
33
#
44
# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
55
# in compliance with the License. You may obtain a copy of the License at
@@ -11,7 +11,7 @@
1111
# or implied. See the License for the specific language governing permissions and limitations under
1212
# the License.
1313
# =============================================================================
14-
file(READ "${CMAKE_CURRENT_LIST_DIR}/VERSION" _rapids_version)
14+
file(READ "${CMAKE_CURRENT_LIST_DIR}/../VERSION" _rapids_version)
1515
if(_rapids_version MATCHES [[^([0-9][0-9])\.([0-9][0-9])\.([0-9][0-9])]])
1616
set(RAPIDS_VERSION_MAJOR "${CMAKE_MATCH_1}")
1717
set(RAPIDS_VERSION_MINOR "${CMAKE_MATCH_2}")
@@ -25,10 +25,5 @@ else()
2525
"Could not determine RAPIDS version. Contents of VERSION file:\n${_rapids_version_formatted}")
2626
endif()
2727

28-
if(NOT EXISTS "${CMAKE_CURRENT_BINARY_DIR}/CUGRAPH_RAPIDS-${RAPIDS_VERSION_MAJOR_MINOR}.cmake")
29-
file(
30-
DOWNLOAD
31-
"https://raw.githubusercontent.com/rapidsai/rapids-cmake/branch-${RAPIDS_VERSION_MAJOR_MINOR}/RAPIDS.cmake"
32-
"${CMAKE_CURRENT_BINARY_DIR}/CUGRAPH_RAPIDS-${RAPIDS_VERSION_MAJOR_MINOR}.cmake")
33-
endif()
34-
include("${CMAKE_CURRENT_BINARY_DIR}/CUGRAPH_RAPIDS-${RAPIDS_VERSION_MAJOR_MINOR}.cmake")
28+
set(rapids-cmake-version "${RAPIDS_VERSION_MAJOR_MINOR}")
29+
include("${CMAKE_CURRENT_LIST_DIR}/RAPIDS.cmake")

cpp/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
cmake_minimum_required(VERSION 3.30.4 FATAL_ERROR)
1818

19-
include(../rapids_config.cmake)
19+
include(../cmake/rapids_config.cmake)
2020
include(rapids-cmake)
2121
include(rapids-cpm)
2222
include(rapids-cuda)

cpp/examples/fetch_dependencies.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# =============================================================================
2-
# Copyright (c) 2024, NVIDIA CORPORATION.
2+
# Copyright (c) 2024-2025, NVIDIA CORPORATION.
33
#
44
# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
55
# in compliance with the License. You may obtain a copy of the License at
@@ -29,5 +29,5 @@ CPMFindPackage(
2929
cpp
3030
)
3131

32-
include(../../../../rapids_config.cmake)
32+
include(../../../../cmake/rapids_config.cmake)
3333
include(rapids-find)

cpp/libcugraph_etl/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
#=============================================================================
1616

1717
cmake_minimum_required(VERSION 3.30.4 FATAL_ERROR)
18-
include(../../rapids_config.cmake)
18+
include(../../cmake/rapids_config.cmake)
1919

2020
include(rapids-cmake)
2121
include(rapids-cpm)

python/cugraph/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
cmake_minimum_required(VERSION 3.30.4 FATAL_ERROR)
1616

17-
include(../../rapids_config.cmake)
17+
include(../../cmake/rapids_config.cmake)
1818

1919
# We always need CUDA for cuML because the raft dependency brings in a
2020
# header-only cuco dependency that enables CUDA unconditionally.

python/libcugraph/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
cmake_minimum_required(VERSION 3.30.4 FATAL_ERROR)
1616

17-
include(../../rapids_config.cmake)
17+
include(../../cmake/rapids_config.cmake)
1818

1919
include(rapids-cuda)
2020
rapids_cuda_init_architectures(libcugraph-python)

python/pylibcugraph/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
cmake_minimum_required(VERSION 3.30.4 FATAL_ERROR)
1616

17-
include(../../rapids_config.cmake)
17+
include(../../cmake/rapids_config.cmake)
1818

1919
# We always need CUDA for cuML because the raft dependency brings in a
2020
# header-only cuco dependency that enables CUDA unconditionally.

0 commit comments

Comments
 (0)