# ESP-NOW radio for the ESP32-P4-Nano: esp-hosted co-processor firmware for its ESP32-C6, plus ESP-NOW over
# esp-hosted peer data (main/radio_now.c). The P4 controller carries this image and updates the C6 when the
# version differs (main/c6_update.c), so the version is a hash of what goes into it.
cmake_minimum_required(VERSION 3.16)
set(_ver_src ${CMAKE_CURRENT_LIST_DIR}/main/radio_now.c ${CMAKE_CURRENT_LIST_DIR}/../bridge/main/radio_proto.h
             ${CMAKE_CURRENT_LIST_DIR}/../bridge/main/bridge_proto.h ${CMAKE_CURRENT_LIST_DIR}/sdkconfig.defaults
             ${CMAKE_CURRENT_LIST_DIR}/main/idf_component.yml)
set(_ver_all "")
foreach(f ${_ver_src})
    file(MD5 ${f} _h)
    string(APPEND _ver_all ${_h})
endforeach()
string(MD5 _ver_hash "${_ver_all}")
string(SUBSTRING ${_ver_hash} 0 10 _ver_short)
set(PROJECT_VER "rc6-${_ver_short}")
# Re-run CMake (and so recompute the version) whenever one of these changes, not only on a fresh build
set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${_ver_src})
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
project(radio_c6)
