version info

version_info

SUBPROJECT

a subproject which helps manage version info generated by cmake for your project, this provides a commit hash to your project while avoiding the use of macros

In your cmakelists.txt do this:

# Retrieve commit hash
execute_process(
        COMMAND git rev-parse --short HEAD
        OUTPUT_VARIABLE COMMIT_HASH
        OUTPUT_STRIP_TRAILING_WHITESPACE
)

# Configure the version_info.cpp file
configure_file(
        "${PROJECT_SOURCE_DIR}/src/version_info/version_info.cpp.in"
        "${PROJECT_SOURCE_DIR}/src/version_info/version_info.cpp"
        @ONLY
)

target_sources(${PROJECT_NAME} PRIVATE "${PROJECT_SOURCE_DIR}/src/version_info/version_info.cpp")

source code

git submodule add git@github.com:cpp-toolbox/version_info.git


edit this page