cmake_minimum_required(VERSION 3.16)

# Firmware version = "<version.txt>-<git short hash>", e.g. 0.0.1-1d613b1. The first part is set by
# hand in version.txt; the hash says which commit was built (no dirty flag: the build always patches
# the cspot submodule). Reported by esp_app_get_description(), status.fw and GET /api/ota.
# CMake re-runs when version.txt or the checked-out commit changes.
set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS
    ${CMAKE_CURRENT_LIST_DIR}/version.txt
    ${CMAKE_CURRENT_LIST_DIR}/.git/logs/HEAD)
file(STRINGS ${CMAKE_CURRENT_LIST_DIR}/version.txt PROJECT_VER LIMIT_COUNT 1)
execute_process(
    COMMAND git rev-parse --short HEAD
    WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
    OUTPUT_VARIABLE GIT_HASH
    OUTPUT_STRIP_TRAILING_WHITESPACE
    ERROR_QUIET)
if(GIT_HASH)
    set(PROJECT_VER "${PROJECT_VER}-${GIT_HASH}")
endif()

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