Skip to content

Commit 5c49aae

Browse files
authored
Merge pull request #1723 from rapidsai/release/26.02
Forward-merge release/26.02 into main
2 parents efe7c97 + b137dd2 commit 5c49aae

2 files changed

Lines changed: 98 additions & 5 deletions

File tree

c/CMakeLists.txt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# =============================================================================
22
# cmake-format: off
3-
# SPDX-FileCopyrightText: Copyright (c) 2025, NVIDIA CORPORATION.
3+
# SPDX-FileCopyrightText: Copyright (c) 2025-2026, NVIDIA CORPORATION.
44
# SPDX-License-Identifier: Apache-2.0
55
# cmake-format: on
66
# =============================================================================
@@ -120,10 +120,10 @@ set_target_properties(
120120
# Long term goal is that every release that breaks the C ABI will update `cuvs_abi_version` allowing
121121
# us to have multiple releases of libcuvs_c that don't need consumers to rebuild against
122122
if(PROJECT_IS_TOP_LEVEL)
123-
set(cuvs_abi_version "1")
124-
set(cuvs_version "${cuvs_abi_version}.${RAPIDS_VERSION}")
125-
set_target_properties(cuvs_c PROPERTIES VERSION "${cuvs_version}")
126-
set_target_properties(cuvs_c PROPERTIES SOVERSION "${cuvs_abi_version}")
123+
include(../cpp/cmake/modules/determine_cuvs_abi_version.cmake)
124+
determine_cuvs_abi_version(${RAPIDS_VERSION} MAJOR abi_major MINOR abi_minor)
125+
set_target_properties(cuvs_c PROPERTIES VERSION "${abi_major}.${abi_minor}")
126+
set_target_properties(cuvs_c PROPERTIES SOVERSION "${abi_major}")
127127
endif()
128128

129129
# Encode what optional components we are building
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
# =============================================================================
2+
# cmake-format: off
3+
# SPDX-FileCopyrightText: Copyright (c) 2026, NVIDIA CORPORATION.
4+
# SPDX-License-Identifier: Apache-2.0
5+
# cmake-format: on
6+
# =============================================================================
7+
include_guard(GLOBAL)
8+
9+
#[=======================================================================[.rst:
10+
determine_cuvs_abi_version
11+
---------------------------
12+
13+
.. versionadded:: v26.02.00
14+
15+
Convert a calendar version to a cuVS ABI version
16+
17+
.. code-block:: cmake
18+
19+
determine_cuvs_abi_version(cal_ver MAJOR major_output_var MINOR minor_output_var)
20+
21+
Provides a consistent method to convert calendar-based version strings (YY.MM format) to
22+
cuVS ABI version components.
23+
24+
Each
25+
26+
``cal_ver``
27+
A calendar version string in YY.MM format (e.g., "26.02", "27.08").
28+
29+
``major_output_var``
30+
Contains the name of the variable that will be set in the parent scope to the computed
31+
ABI major version.
32+
33+
``minor_output_var``
34+
Contains the name of the variable that will be set in the parent scope to the computed
35+
ABI minor version.
36+
37+
Example on how to properly use :cmake:command:`determine_cuvs_abi_version`:
38+
39+
.. code-block:: cmake
40+
41+
project(Example VERSION 26.02.0)
42+
43+
determine_cuvs_abi_version(${PROJECT_VERSION} MAJOR abi_major MINOR abi_minor)
44+
message(STATUS "CalVer ${calver} maps to ABI ${abi_major}.${abi_minor}")
45+
46+
47+
Result Variables
48+
^^^^^^^^^^^^^^^^
49+
Variables matching the contents of ``major_output_var`` and ``minor_output_var`` will be set in the parent
50+
scope with the computed ABI version components.
51+
52+
``${major_output_var}``
53+
Contains the ABI major version component
54+
55+
``${minor_output_var}``
56+
Contains the ABI minor version component
57+
58+
#]=======================================================================]
59+
# cmake-lint: disable=C0112
60+
function(determine_cuvs_abi_version cal_ver)
61+
set(options)
62+
set(one_value "MAJOR" "MINOR")
63+
set(multi_value)
64+
cmake_parse_arguments(_CUVS_RAPIDS "${options}" "${one_value}" "${multi_value}" ${ARGN})
65+
66+
rapids_cmake_parse_version(MAJOR ${cal_ver} cal_ver_major)
67+
rapids_cmake_parse_version(MINOR ${cal_ver} cal_ver_minor)
68+
69+
# Encode the last ABI break
70+
set(current_major_abi_ver "1") # The current ABI major value
71+
set(abi_base_year "26") # What year the current ABI major occurred in
72+
set(abi_base_month "04") # What month the current ABI major occurred in
73+
# compute the abi version
74+
if(cal_ver_major STREQUAL abi_base_year)
75+
# If we are in the same year is is pretty easy to compute our abi break
76+
math(EXPR computed_abi_minor "(${cal_ver_minor}-${abi_base_month})/2")
77+
else()
78+
#
79+
math(EXPR first_year_count "(12-${abi_base_month})/2")
80+
math(EXPR extra_years "(${cal_ver_major} - ${abi_base_year} - 1) * 6")
81+
math(EXPR this_year_count "(${cal_ver_minor})/2")
82+
math(EXPR computed_abi_minor "${first_year_count} + ${extra_years} + ${this_year_count}")
83+
endif()
84+
85+
set(${_CUVS_RAPIDS_MAJOR}
86+
${computed_abi_major}
87+
PARENT_SCOPE
88+
)
89+
set(${_CUVS_RAPIDS_MINOR}
90+
${computed_abi_minor}
91+
PARENT_SCOPE
92+
)
93+
endfunction()

0 commit comments

Comments
 (0)