Skip to content

Commit 2aee755

Browse files
authored
Vendor RAPIDS.cmake (rapidsai#816)
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: rapidsai/build-infra#206 Authors: - Bradley Dice (https://github.com/bdice) Approvers: - Kyle Edwards (https://github.com/KyleFromNVIDIA) URL: rapidsai#816
1 parent 7cf01c2 commit 2aee755

7 files changed

Lines changed: 99 additions & 15 deletions

File tree

cmake/RAPIDS.cmake

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
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+
)
77+
else()
78+
string(APPEND rapids-cmake-url "${rapids-cmake-value-to-clone}")
79+
FetchContent_Declare(rapids-cmake URL "${rapids-cmake-url}")
80+
endif()
81+
FetchContent_GetProperties(rapids-cmake)
82+
if(rapids-cmake_POPULATED)
83+
# Something else has already populated rapids-cmake, only thing we need to do is setup the
84+
# CMAKE_MODULE_PATH
85+
if(NOT "${rapids-cmake-dir}" IN_LIST CMAKE_MODULE_PATH)
86+
list(APPEND CMAKE_MODULE_PATH "${rapids-cmake-dir}")
87+
endif()
88+
else()
89+
FetchContent_MakeAvailable(rapids-cmake)
90+
endif()
Lines changed: 4 additions & 10 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}")
@@ -26,11 +26,5 @@ else()
2626
)
2727
endif()
2828

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

cpp/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
# or implied. See the License for the specific language governing permissions and limitations under
1212
# the License.
1313
cmake_minimum_required(VERSION 3.30.4 FATAL_ERROR)
14-
include(../rapids_config.cmake)
14+
include(../cmake/rapids_config.cmake)
1515
include(rapids-cmake)
1616
include(rapids-cpm)
1717
include(rapids-export)

java/internal/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
include(rapids-cmake)
1919
include(rapids-cpm)
2020
include(rapids-export)

python/cuvs/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 cuvs because the cuvs dependency brings in a header-only cuco dependency
2020
# that enables CUDA unconditionally.

python/libcuvs/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(libcuvs-python)

rust/cuvs-sys/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
include(rapids-cmake)
1919
include(rapids-cpm)
2020
include(rapids-export)

0 commit comments

Comments
 (0)