Skip to content

Commit

Permalink
Read version from VERSION file in CMake (rapidsai#14867)
Browse files Browse the repository at this point in the history
Rather than hard-coding the RAPIDS version throughout CMake code, have a single CMake module that reads it from `VERSION` and provides it as a variable.

Authors:
  - Kyle Edwards (https://github.com/KyleFromNVIDIA)

Approvers:
  - Bradley Dice (https://github.com/bdice)
  - Robert Maynard (https://github.com/robertmaynard)
  - Jason Lowe (https://github.com/jlowe)
  - Charles Blackmon-Luca (https://github.com/charlesbluca)
  - Ray Douglass (https://github.com/raydouglass)
  - GALI PREM SAGAR (https://github.com/galipremsagar)

URL: rapidsai#14867
  • Loading branch information
KyleFromNVIDIA authored Feb 22, 2024
1 parent 6f6e521 commit 296185c
Show file tree
Hide file tree
Showing 8 changed files with 48 additions and 51 deletions.
16 changes: 0 additions & 16 deletions ci/release/update-version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,28 +38,12 @@ function sed_runner() {
sed -i.bak ''"$1"'' $2 && rm -f ${2}.bak
}

# cpp update
sed_runner 's/'"VERSION ${CURRENT_SHORT_TAG}.*"'/'"VERSION ${NEXT_FULL_TAG}"'/g' cpp/CMakeLists.txt

# Python CMakeLists updates
sed_runner 's/'"cudf_version .*)"'/'"cudf_version ${NEXT_FULL_TAG})"'/g' python/cudf/CMakeLists.txt
sed_runner 's/'"cudf_kafka_version .*)"'/'"cudf_kafka_version ${NEXT_FULL_TAG})"'/g' python/cudf_kafka/CMakeLists.txt

# cpp libcudf_kafka update
sed_runner 's/'"VERSION ${CURRENT_SHORT_TAG}.*"'/'"VERSION ${NEXT_FULL_TAG}"'/g' cpp/libcudf_kafka/CMakeLists.txt

# cpp cudf_jni update
sed_runner 's/'"VERSION ${CURRENT_SHORT_TAG}.*"'/'"VERSION ${NEXT_FULL_TAG}"'/g' java/src/main/native/CMakeLists.txt

# Centralized version file update
echo "${NEXT_FULL_TAG}" > VERSION

# Wheel testing script
sed_runner "s/branch-.*/branch-${NEXT_SHORT_TAG}/g" ci/test_wheel_dask_cudf.sh

# rapids-cmake version
sed_runner 's/'"branch-.*\/RAPIDS.cmake"'/'"branch-${NEXT_SHORT_TAG}\/RAPIDS.cmake"'/g' fetch_rapids.cmake

# cmake-format rapids-cmake definitions
sed_runner 's/'"branch-.*\/cmake-format-rapids-cmake.json"'/'"branch-${NEXT_SHORT_TAG}\/cmake-format-rapids-cmake.json"'/g' ci/check_style.sh

Expand Down
4 changes: 2 additions & 2 deletions cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

cmake_minimum_required(VERSION 3.26.4 FATAL_ERROR)

include(../fetch_rapids.cmake)
include(../rapids_config.cmake)
include(rapids-cmake)
include(rapids-cpm)
include(rapids-cuda)
Expand All @@ -26,7 +26,7 @@ rapids_cuda_init_architectures(CUDF)

project(
CUDF
VERSION 24.04.00
VERSION "${RAPIDS_VERSION}"
LANGUAGES C CXX CUDA
)
if(CMAKE_CUDA_COMPILER_ID STREQUAL "NVIDIA" AND CMAKE_CUDA_COMPILER_VERSION VERSION_LESS 11.5)
Expand Down
4 changes: 2 additions & 2 deletions cpp/libcudf_kafka/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# =============================================================================
cmake_minimum_required(VERSION 3.26.4 FATAL_ERROR)

include(../../fetch_rapids.cmake)
include(../../rapids_config.cmake)
include(rapids-cmake)
include(rapids-cpm)
include(rapids-cuda)
Expand All @@ -22,7 +22,7 @@ include(rapids-find)

project(
CUDF_KAFKA
VERSION 24.04.00
VERSION "${RAPIDS_VERSION}"
LANGUAGES CXX
)

Expand Down
19 changes: 0 additions & 19 deletions fetch_rapids.cmake

This file was deleted.

4 changes: 2 additions & 2 deletions java/src/main/native/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# =============================================================================
cmake_minimum_required(VERSION 3.26.4 FATAL_ERROR)

include(../../../../fetch_rapids.cmake)
include(../../../../rapids_config.cmake)
include(rapids-cmake)
include(rapids-cuda)
include(rapids-find)
Expand All @@ -28,7 +28,7 @@ rapids_cuda_init_architectures(CUDF_JNI)

project(
CUDF_JNI
VERSION 24.04.00
VERSION "${RAPIDS_VERSION}"
LANGUAGES C CXX CUDA
)

Expand Down
8 changes: 3 additions & 5 deletions python/cudf/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,13 @@

cmake_minimum_required(VERSION 3.26.4 FATAL_ERROR)

set(cudf_version 24.04.00)

include(../../fetch_rapids.cmake)
include(../../rapids_config.cmake)
include(rapids-cuda)
rapids_cuda_init_architectures(cudf-python)

project(
cudf-python
VERSION ${cudf_version}
VERSION "${RAPIDS_VERSION}"
LANGUAGES CXX CUDA
)

Expand Down Expand Up @@ -55,7 +53,7 @@ if(FIND_CUDF_CPP)
include(../../cpp/cmake/thirdparty/get_arrow.cmake)
endif()

find_package(cudf ${cudf_version} REQUIRED)
find_package(cudf "${RAPIDS_VERSION}" REQUIRED)

# an installed version of libcudf doesn't provide the dlpack headers so we need to download dlpack
# for the interop.pyx
Expand Down
8 changes: 3 additions & 5 deletions python/cudf_kafka/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,15 @@

cmake_minimum_required(VERSION 3.26.4 FATAL_ERROR)

set(cudf_kafka_version 24.04.00)

include(../../fetch_rapids.cmake)
include(../../rapids_config.cmake)

project(
cudf-kafka-python
VERSION ${cudf_kafka_version}
VERSION "${RAPIDS_VERSION}"
LANGUAGES CXX
)

find_package(cudf_kafka ${cudf_kafka_version} REQUIRED)
find_package(cudf_kafka "${RAPIDS_VERSION}" REQUIRED)

if(NOT cudf_kafka_FOUND)
message(
Expand Down
36 changes: 36 additions & 0 deletions rapids_config.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# =============================================================================
# Copyright (c) 2018-2024, NVIDIA CORPORATION.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
# in compliance with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software distributed under the License
# is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
# or implied. See the License for the specific language governing permissions and limitations under
# the License.
# =============================================================================
file(READ "${CMAKE_CURRENT_LIST_DIR}/VERSION" _rapids_version)
if(_rapids_version MATCHES [[^([0-9][0-9])\.([0-9][0-9])\.([0-9][0-9])]])
set(RAPIDS_VERSION_MAJOR "${CMAKE_MATCH_1}")
set(RAPIDS_VERSION_MINOR "${CMAKE_MATCH_2}")
set(RAPIDS_VERSION_PATCH "${CMAKE_MATCH_3}")
set(RAPIDS_VERSION_MAJOR_MINOR "${RAPIDS_VERSION_MAJOR}.${RAPIDS_VERSION_MINOR}")
set(RAPIDS_VERSION "${RAPIDS_VERSION_MAJOR}.${RAPIDS_VERSION_MINOR}.${RAPIDS_VERSION_PATCH}")
else()
string(REPLACE "\n" "\n " _rapids_version_formatted " ${_rapids_version}")
message(
FATAL_ERROR
"Could not determine RAPIDS version. Contents of VERSION file:\n${_rapids_version_formatted}"
)
endif()

if(NOT EXISTS "${CMAKE_CURRENT_BINARY_DIR}/CUDF_RAPIDS-${RAPIDS_VERSION_MAJOR_MINOR}.cmake")
file(
DOWNLOAD
"https://raw.githubusercontent.com/rapidsai/rapids-cmake/branch-${RAPIDS_VERSION_MAJOR_MINOR}/RAPIDS.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/CUDF_RAPIDS-${RAPIDS_VERSION_MAJOR_MINOR}.cmake"
)
endif()
include("${CMAKE_CURRENT_BINARY_DIR}/CUDF_RAPIDS-${RAPIDS_VERSION_MAJOR_MINOR}.cmake")

0 comments on commit 296185c

Please sign in to comment.