# For more information about build system see
# https://docs.espressif.com/projects/esp-idf/en/latest/api-guides/build-system.html
# The following five lines of boilerplate have to be in your project's
# CMakeLists in this exact order for cmake to work correctly
cmake_minimum_required(VERSION 3.5)

include($ENV{IDF_PATH}/tools/cmake/project.cmake)
project(main)

idf_build_get_property(build_dir BUILD_DIR)
idf_build_get_property(elf_name  EXECUTABLE_NAME GENERATOR_EXPRESSION)

# Fake target to always increment the version number on each build.
add_custom_command (OUTPUT ${CMAKE_SOURCE_DIR}/updated
    DEPENDS "${build_dir}/.bin_timestamp"
    COMMAND bash -c "${CMAKE_SOURCE_DIR}/backup_version.sh"
    COMMAND bash -c "${CMAKE_SOURCE_DIR}/update_version.sh"
    COMMAND bash -c "${CMAKE_SOURCE_DIR}/make_filepack.sh"
    COMMAND bash -c "${CMAKE_SOURCE_DIR}/make_release.sh"
)

add_custom_target(version ALL DEPENDS ${CMAKE_SOURCE_DIR}/updated)
