function(pp_add_version_generation target config_name)
    find_package(Python3 COMPONENTS Interpreter REQUIRED)

    add_custom_command(
        OUTPUT "${CMAKE_CURRENT_SOURCE_DIR}/src/version.gen.h"
        COMMAND "${Python3_EXECUTABLE}" "${CMAKE_CURRENT_SOURCE_DIR}/scripts/pre-build.py" "${config_name}"
        WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
        DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/scripts/pre-build.py"
        COMMENT "Generating src/version.gen.h"
        VERBATIM)

    add_custom_target(pp_generate_version
        DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/src/version.gen.h")

    add_dependencies(${target} pp_generate_version)
endfunction()

