Skip to content

Masfo/buildinc

Repository files navigation

buildinc (Visual Studio 2022)

Updates build versions automatically.

Usage example: buildinc output.h Example

Generates C++ header file containing version and build numbers. Also included

  • random number seed
  • random code phrase.
  • compile time

Example output:

Example: add custom command to your CMake script to update per build.

find_program(BUILDINC_TOOL "buildinc" NO_CACHE)

// Header
add_custom_command(TARGET <your_target>
                   PRE_BUILD
                   COMMAND ${BUILDINC_TOOL} ${CMAKE_CURRENT_SOURCE_DIR}/src/buildnumber.h BuildInc -q 
                   WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/src
                   COMMENT "Increase build number"
)
find_program(BUILDINC_TOOL "buildinc" NO_CACHE)

// Module
add_custom_command(TARGET <your_target>
                   PRE_BUILD
                   COMMAND ${BUILDINC_TOOL} ${CMAKE_CURRENT_SOURCE_DIR}/src/buildnumber.ixx BuildInc -q -m
                   WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/src
                   COMMENT "Increase build number"
)

Clang-Format check