# Copyright 2023 jacqueline <me@jacqueline.id.au>
#
# SPDX-License-Identifier: CC0-1.0
# For more information about build system see
# https://docs.espressif.com/projects/esp-idf/en/latest/api-guides/build-system.html
set ( PROJECT_VER "1.3.1" )
# esp-idf sets the C++ standard weird. Set cmake vars to match.
set ( CMAKE_CXX_STANDARD 23 )
set ( CMAKE_CXX_EXTENSIONS ON )
# Build only the subset of components that we actually depend on.
set ( COMPONENTS "" )
# External dependencies
list ( APPEND EXTRA_COMPONENT_DIRS "$ENV{PROJ_PATH}/lib/bt" )
list ( APPEND EXTRA_COMPONENT_DIRS "$ENV{PROJ_PATH}/lib/catch2" )
list ( APPEND EXTRA_COMPONENT_DIRS "$ENV{PROJ_PATH}/lib/cbor" )
list ( APPEND EXTRA_COMPONENT_DIRS "$ENV{PROJ_PATH}/lib/console" )
list ( APPEND EXTRA_COMPONENT_DIRS "$ENV{PROJ_PATH}/lib/esp-idf-lua" )
list ( APPEND EXTRA_COMPONENT_DIRS "$ENV{PROJ_PATH}/lib/fatfs" )
list ( APPEND EXTRA_COMPONENT_DIRS "$ENV{PROJ_PATH}/lib/komihash" )
list ( APPEND EXTRA_COMPONENT_DIRS "$ENV{PROJ_PATH}/lib/libcppbor" )
list ( APPEND EXTRA_COMPONENT_DIRS "$ENV{PROJ_PATH}/lib/libmad" )
list ( APPEND EXTRA_COMPONENT_DIRS "$ENV{PROJ_PATH}/lib/libtags" )
list ( APPEND EXTRA_COMPONENT_DIRS "$ENV{PROJ_PATH}/lib/lua-linenoise" )
list ( APPEND EXTRA_COMPONENT_DIRS "$ENV{PROJ_PATH}/lib/lua-term" )
list ( APPEND EXTRA_COMPONENT_DIRS "$ENV{PROJ_PATH}/lib/luavgl" )
list ( APPEND EXTRA_COMPONENT_DIRS "$ENV{PROJ_PATH}/lib/lvgl" )
list ( APPEND EXTRA_COMPONENT_DIRS "$ENV{PROJ_PATH}/lib/millershuffle" )
list ( APPEND EXTRA_COMPONENT_DIRS "$ENV{PROJ_PATH}/lib/drflac" )
list ( APPEND EXTRA_COMPONENT_DIRS "$ENV{PROJ_PATH}/lib/ogg" )
list ( APPEND EXTRA_COMPONENT_DIRS "$ENV{PROJ_PATH}/lib/opusfile" )
list ( APPEND EXTRA_COMPONENT_DIRS "$ENV{PROJ_PATH}/lib/result" )
list ( APPEND EXTRA_COMPONENT_DIRS "$ENV{PROJ_PATH}/lib/speexdsp" )
list ( APPEND EXTRA_COMPONENT_DIRS "$ENV{PROJ_PATH}/lib/tinyfsm" )
list ( APPEND EXTRA_COMPONENT_DIRS "$ENV{PROJ_PATH}/lib/tremor" )
list ( APPEND EXTRA_COMPONENT_DIRS "$ENV{PROJ_PATH}/lib/wavpack" )
include ( $ENV{ IDF_PATH } /tools/cmake/project.cmake )
# Additional warnings used when compiling our components.
# Unable to be used due to issues in ESP-IDF includes are: -Wpedantic
# -Wuseless-cast -Wconversion -Wold-style-cast -Wsign-conversion -Wcast-align
set ( EXTRA_WARNINGS "-Wnon-virtual-dtor" "-Wunused" "-Woverloaded-virtual"
" - W m i s l e a d i n g - i n d e n t a t i o n " " - W d u p l i c a t e d - c o n d " " - W d u p l i c a t e d - b r a n c h e s "
" - W l o g i c a l - o p " " - W n u l l - d e r e f e r e n c e " " - W d o u b l e - p r o m o t i o n " " - W f o r m a t = 2 "
" - W i m p l i c i t - f a l l t h r o u g h " " - W n o - d e p r e c a t e d - e n u m - e n u m - c o n v e r s i o n "
" - W n o - a r r a y - b o u n d s " " - W n o - m i s s i n g - f i e l d - i n i t i a l i z e r s " )
# Extra build flags that should apply to the entire build. This should mostly
# just be used to setting flags that our external dependencies requires.
# Otherwise, prefer adding per-component build flags to keep things neat.
idf_build_set_property ( COMPILE_OPTIONS "-DLV_CONF_INCLUDE_SIMPLE" APPEND )
idf_build_set_property ( COMPILE_OPTIONS "-DTCB_SPAN_NAMESPACE_NAME=cpp" APPEND )