rapids_cmake_parse_version

Added in version v21.06.00.

Extract components of a X.Y.Z or X.Y version string in a consistent manner

rapids_cmake_parse_version( [MAJOR|MINOR|PATCH|MAJOR_MINOR] version out_variable_name)

Offers the ability to extract components of any 2 or 3 component version string without having to write complex regular expressions.

MAJOR

Extract the first component (X) from version and place it in the variable named in out_variable_name

MINOR

Extract the second component (Y) from version and place it in the variable named in out_variable_name

PATCH

Extract the third component (Z) from version and place it in the variable named in out_variable_name. If no Z component exists for version nothing will happen.

MAJOR_MINOR

Extract the first and second component (X.Y) from version and place it in the variable named in out_variable_name using the pattern X.Y.

Example on how to properly use rapids_cmake_parse_version():

project(Example VERSION 43.01.0)

rapids_cmake_parse_version(MAJOR_MINOR ${PROJECT_VERSION} major_minor)
message(STATUS "The major.minor version is: ${major_minor}")

Result Variables

The variable out_variable_name will be created/modified only when the version extraction is successful