rapids_cmake_write_version_file

Added in version v21.08.00.

Generate a C++ header file that hold the version (X.Y.Z) information of the calling project.

rapids_cmake_write_version_file(file_path [PREFIX <prefix>])

The file generated by rapids_cmake_write_version_file() holds the separate components of the X.Y.Z version string set by the CMake project call as C++ defines.

PREFIX

Prefix for all the C++ macros. By default if not explicitly specified it will be equal to the projects name ( CMake variable PROJECT_NAME ).

The generated file will be contain the following unconditionally defines:

  • #define <PREFIX>_VERSION_MAJOR # CMake’s PROJECT_VERSION_MAJOR (X)

  • #define <PREFIX>_VERSION_MINOR # CMake’s PROJECT_VERSION_MINOR (Y)

  • #define <PREFIX>_VERSION_PATCH # CMake’s PROJECT_VERSION_PATCH (Z)

Each of the components will have all leading zeroes removed as we presume all components of the version can be represented as decimal values.

Note

If a component doesn’t exist, zero will be used as a placeholder value. For example version 2.4 the PATCH value will become 0.

file_path

Either an absolute or relative path. When a relative path, the absolute location will be computed from CMAKE_CURRENT_BINARY_DIR