Skip to content

Commit 492d474

Browse files
rapids-cmake: Add support for a version suffix to mean using main (#864)
To support the new RAPIDS wide branching model rapids-cmake has to support switching between the `main` branch for `rapids_cpm_rmm` and a release branch like `branch-25.06`. This is implemented by reading the rapids-cmake `VERSION` file and when we detect a value that ends in `a` we know we are being used from the `main` branch (a development version) and not from a release branch. Fixes #863 Authors: - Robert Maynard (https://github.com/robertmaynard) Approvers: - Vyas Ramasubramani (https://github.com/vyasr) - Bradley Dice (https://github.com/bdice) URL: #864
1 parent 86b956a commit 492d474

File tree

12 files changed

+41
-20
lines changed

12 files changed

+41
-20
lines changed

docs/cpm.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ as needed.
156156
installed copy of the project can't be found.
157157

158158
Supports the following placeholders:
159+
- ``${rapids-cmake-checkout-tag}`` will be evaluated to ``main`` when using rapids-cmake ``main`` branch, or ``branch-<major>.<minor>`` when not on the 'main' branch, using the rapids-cmake CalVer values.
159160
- ``${rapids-cmake-version}`` will be evaluated to 'major.minor' of the current rapids-cmake cal-ver value.
160161
- ``${version}`` will be evaluated to the contents of the ``version`` field.
161162
- ``$ENV{variable}`` will be evaluated to the contents of the listed environment variable

rapids-cmake/cpm/detail/get_proprietary_binary_url.cmake

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#=============================================================================
2-
# Copyright (c) 2023-2024, NVIDIA CORPORATION.
2+
# Copyright (c) 2023-2025, NVIDIA CORPORATION.
33
#
44
# Licensed under the Apache License, Version 2.0 (the "License");
55
# you may not use this file except in compliance with the License.
@@ -56,12 +56,9 @@ function(rapids_cpm_get_proprietary_binary_url package_name version url_var)
5656
return()
5757
endif()
5858

59-
if(NOT DEFINED rapids-cmake-version)
60-
include("${rapids-cmake-dir}/rapids-version.cmake")
61-
endif()
62-
6359
# Determine the CUDA Toolkit version so that we properly evaluate the placeholders in
6460
# `proprietary_binary`
61+
include("${rapids-cmake-dir}/rapids-version.cmake")
6562
if(proprietary_binary MATCHES "{cuda-toolkit-version")
6663
find_package(CUDAToolkit REQUIRED)
6764
set(cuda-toolkit-version ${CUDAToolkit_VERSION_MAJOR}.${CUDAToolkit_VERSION_MINOR})

rapids-cmake/cpm/detail/package_details.cmake

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,10 +110,8 @@ function(rapids_cpm_package_details package_name version_var url_var tag_var sha
110110
rapids_cpm_json_get_value(always_download)
111111

112112
# Evaluate any magic placeholders in the version or tag components including the
113-
# `rapids-cmake-version` value
114-
if(NOT DEFINED rapids-cmake-version)
115-
include("${rapids-cmake-dir}/rapids-version.cmake")
116-
endif()
113+
# `rapids-cmake-version` and `rapids-cmake-checkout-tag` values
114+
include("${rapids-cmake-dir}/rapids-version.cmake")
117115

118116
cmake_language(EVAL CODE "set(version ${version})")
119117
cmake_language(EVAL CODE "set(git_tag ${git_tag})")

rapids-cmake/cpm/versions.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@
7272
"rmm": {
7373
"version": "${rapids-cmake-version}",
7474
"git_url": "https://github.com/rapidsai/rmm.git",
75-
"git_tag": "branch-${version}"
75+
"git_tag": "${rapids-cmake-checkout-tag}"
7676
},
7777
"spdlog": {
7878
"version": "1.14.1",

rapids-cmake/rapids-version.cmake

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,27 @@
1616
# can't have an include guard on this file
1717
# that breaks its usage by cpm/detail/package_details
1818

19-
if(NOT DEFINED rapids-cmake-version)
19+
if(NOT DEFINED rapids-cmake-checkout-tag)
2020
file(READ "${CMAKE_CURRENT_LIST_DIR}/../VERSION" _rapids_version)
21-
if(_rapids_version MATCHES [[^([0-9][0-9])\.([0-9][0-9])\.([0-9][0-9])]])
21+
if(_rapids_version MATCHES [[^([0-9][0-9])\.([0-9][0-9])\.([0-9][0-9])(a?)]])
2222
set(RAPIDS_VERSION_MAJOR "${CMAKE_MATCH_1}")
2323
set(RAPIDS_VERSION_MINOR "${CMAKE_MATCH_2}")
2424
set(RAPIDS_VERSION_PATCH "${CMAKE_MATCH_3}")
25+
set(RAPIDS_USE_MAIN "${CMAKE_MATCH_4}")
2526
set(RAPIDS_VERSION_MAJOR_MINOR "${RAPIDS_VERSION_MAJOR}.${RAPIDS_VERSION_MINOR}")
2627
set(RAPIDS_VERSION "${RAPIDS_VERSION_MAJOR}.${RAPIDS_VERSION_MINOR}.${RAPIDS_VERSION_PATCH}")
2728
else()
2829
string(REPLACE "\n" "\n " _rapids_version_formatted " ${_rapids_version}")
2930
message(FATAL_ERROR "Could not determine RAPIDS version. Contents of VERSION file:\n${_rapids_version_formatted}"
3031
)
3132
endif()
32-
set(rapids-cmake-version ${RAPIDS_VERSION_MAJOR_MINOR})
33+
34+
if(NOT DEFINED rapids-cmake-version)
35+
set(rapids-cmake-version ${RAPIDS_VERSION_MAJOR_MINOR})
36+
endif()
37+
38+
set(rapids-cmake-checkout-tag "branch-${RAPIDS_VERSION_MAJOR_MINOR}")
39+
if(RAPIDS_USE_MAIN)
40+
set(rapids-cmake-checkout-tag "main")
41+
endif()
3342
endif()

testing/cpm/cpm_init-override-multiple.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/default.json
4242
"rmm": {
4343
"version": "${rapids-cmake-version}",
4444
"git_url": "https://github.com/rapidsai/rmm.git",
45-
"git_tag": "branch-${version}"
45+
"git_tag": "${rapids-cmake-checkout-tag}"
4646
},
4747
"GTest": {
4848
"version": "1.16.0",

testing/cpm/cpm_package_override-defaults-with-different-casing.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/default.json
2525
"rmm": {
2626
"version": "${rapids-cmake-version}",
2727
"git_url": "https://github.com/rapidsai/rmm.git",
28-
"git_tag": "branch-${version}"
28+
"git_tag": "${rapids-cmake-checkout-tag}"
2929
},
3030
"GTest": {
3131
"version": "1.16.0",

testing/cpm/cpm_package_override-simple.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/default.json
2424
"rmm": {
2525
"version": "${rapids-cmake-version}",
2626
"git_url": "https://github.com/rapidsai/rmm.git",
27-
"git_tag": "branch-${version}"
27+
"git_tag": "${rapids-cmake-checkout-tag}"
2828
},
2929
"GTest": {
3030
"version": "1.16.0",

testing/other/rapids_cmake-multiple-cpm/A/CMakeLists.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#=============================================================================
2-
# Copyright (c) 2021, NVIDIA CORPORATION.
2+
# Copyright (c) 2021-2025, NVIDIA CORPORATION.
33
#
44
# Licensed under the Apache License, Version 2.0 (the "License");
55
# you may not use this file except in compliance with the License.
@@ -37,5 +37,9 @@ if(NOT DEFINED rapids-cmake-version)
3737
message(FATAL_ERROR "expected variable rapids-cmake-version to exist")
3838
endif()
3939

40+
if(NOT DEFINED rapids-cmake-checkout-tag)
41+
message(FATAL_ERROR "expected variable rapids-cmake-checkout-tag to exist")
42+
endif()
43+
4044
# Be hostile against rapids-cmake
4145
set(CMAKE_MODULE_PATH "/not/a/directory")

testing/other/rapids_cmake-multiple-cpm/B/CMakeLists.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#=============================================================================
2-
# Copyright (c) 2021, NVIDIA CORPORATION.
2+
# Copyright (c) 2021-2025, NVIDIA CORPORATION.
33
#
44
# Licensed under the Apache License, Version 2.0 (the "License");
55
# you may not use this file except in compliance with the License.
@@ -36,3 +36,7 @@ endif()
3636
if(NOT DEFINED rapids-cmake-version)
3737
message(FATAL_ERROR "expected variable rapids-cmake-version to exist")
3838
endif()
39+
40+
if(NOT DEFINED rapids-cmake-checkout-tag)
41+
message(FATAL_ERROR "expected variable rapids-cmake-checkout-tag to exist")
42+
endif()

0 commit comments

Comments
 (0)