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>] [NO_COMBINED_VERSION_MACRO])

The file generated by rapids_cmake_write_version_file() holds the full version, the separate components, and comparison helpers for 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 ).

NO_COMBINED_VERSION_MACRO

Added in version v26.10.00.

Don’t generate the <PREFIX>_VERSION define. Useful for projects that already define <PREFIX>_VERSION themselves with a different meaning, as the two definitions would otherwise conflict. All other defines are still generated.

The generated file will contain the following defines:

  • #define <PREFIX>_VERSION “X.Y.Z” # Unless NO_COMBINED_VERSION_MACRO is specified

  • #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)

  • #define <PREFIX>_VERSION_GT(maj, min, pat) # True when X.Y.Z is greater than maj.min.pat

  • #define <PREFIX>_VERSION_LT(maj, min, pat) # True when X.Y.Z is less than maj.min.pat

  • #define <PREFIX>_VERSION_EQ(maj, min, pat) # True when X.Y.Z is equal to maj.min.pat

Added in version v26.08.00: The <PREFIX>_VERSION, <PREFIX>_VERSION_GT, <PREFIX>_VERSION_LT, and <PREFIX>_VERSION_EQ defines.

Each of the components and the <PREFIX>_VERSION string 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