cmake_minimum_required(VERSION 3.16)

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

# LVGL is configured by our own lv_conf.h, not by its Kconfig menu
# (CONFIG_LV_CONF_SKIP=n in sdkconfig.defaults). LV_CONF_PATH must be an
# absolute path, must be a quoted string (lv_conf_internal.h does
# `#include LV_CONF_PATH`), and must be set before project() so it reaches
# the lvgl component's compile as well as ours. It must also come *after*
# the include above: idf_build_set_property is defined by IDF's build.cmake,
# which project.cmake pulls in via idf.cmake.
idf_build_set_property(COMPILE_OPTIONS
    "-DLV_CONF_PATH=\"${CMAKE_CURRENT_LIST_DIR}/main/lv_conf.h\"" APPEND)

# The app version compiled into the image is the repo's VERSION file, the
# same string flashing/build_release.py puts in the .bin's file name. IDF
# would otherwise use `git describe`, which names a commit nobody at 150
# Bond can map to a release. Setting PROJECT_VER before project() is the
# documented override (tools/cmake/project.cmake, "If PROJECT_VER has not
# been set yet"). Re-configure when VERSION changes.
file(STRINGS "${CMAKE_CURRENT_LIST_DIR}/../VERSION" PROJECT_VER LIMIT_COUNT 1)
set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS "${CMAKE_CURRENT_LIST_DIR}/../VERSION")

project(magic8)
