# CROSS COMPILER SETTING
SET(CMAKE_SYSTEM_NAME Generic)
CMAKE_MINIMUM_REQUIRED (VERSION 3.10.0)

# THE VERSION NUMBER
SET (Tutorial_VERSION_MAJOR 1)
SET (Tutorial_VERSION_MINOR 0)

# ENABLE ASM
ENABLE_LANGUAGE(ASM)

SET(CMAKE_STATIC_LIBRARY_PREFIX)
SET(CMAKE_STATIC_LIBRARY_SUFFIX)

SET(CMAKE_EXECUTABLE_LIBRARY_PREFIX)
SET(CMAKE_EXECUTABLE_LIBRARY_SUFFIX)

# CURRENT DIRECTORY
SET(ProjDirPath ${CMAKE_CURRENT_SOURCE_DIR})

SET(EXECUTABLE_OUTPUT_PATH ${ProjDirPath}/${CMAKE_BUILD_TYPE})
SET(LIBRARY_OUTPUT_PATH ${ProjDirPath}/${CMAKE_BUILD_TYPE})


project(deepviewrt_modelrunner-tflite)

set(MCUX_SDK_PROJECT_NAME deepviewrt_modelrunner-tflite.elf)

include(${ProjDirPath}/flags.cmake)

include(${ProjDirPath}/config.cmake)

add_executable(${MCUX_SDK_PROJECT_NAME} 
"${ProjDirPath}/../source/main.c"
"${ProjDirPath}/../source/lwipopts.h"
"${ProjDirPath}/../source/FreeRTOSConfig.h"
"${ProjDirPath}/../source/modelrunner.h"
"${ProjDirPath}/../source/modelrunner_server.h"
"${ProjDirPath}/../source/modelrunner.c"
"${ProjDirPath}/../source/http_handler.c"
"${ProjDirPath}/../source/tf_benchmark.cpp"
"${ProjDirPath}/../source/tf_benchmark.h"
"${ProjDirPath}/../source/picohttp.c"
"${ProjDirPath}/../source/picohttp.h"
"${ProjDirPath}/../source/model.h"
"${ProjDirPath}/../source/picohttpparser.c"
"${ProjDirPath}/../source/picohttpparser.h"
"${ProjDirPath}/../source/get_top_n.cpp"
"${ProjDirPath}/../source/get_top_n.h"
"${ProjDirPath}/../pin_mux.h"
"${ProjDirPath}/../pin_mux.c"
"${ProjDirPath}/../clock_config.c"
"${ProjDirPath}/../clock_config.h"
"${ProjDirPath}/../dcd.c"
"${ProjDirPath}/../dcd.h"
"${ProjDirPath}/../board.h"
"${ProjDirPath}/../pca6416.c"
"${ProjDirPath}/../pca6416.h"
"${ProjDirPath}/../pca9530.c"
"${ProjDirPath}/../pca9530.h"
"${ProjDirPath}/../mac_addr.c"
"${ProjDirPath}/../mac_addr.h"
"${ProjDirPath}/../board.c"
)

target_include_directories(${MCUX_SDK_PROJECT_NAME} PRIVATE
    ${ProjDirPath}/../source
    ${ProjDirPath}/..
    ${ProjDirPath}/../../../../../rtos/freertos/libraries/abstractions/posix/include
)

set(CMAKE_MODULE_PATH
    ${ProjDirPath}/../../../../../middleware/lwip
    ${ProjDirPath}/../../../../../rtos/freertos/freertos_kernel
    ${ProjDirPath}/../../../../../components/phy
    ${ProjDirPath}/../../../../../devices/MIMXRT1064/drivers
    ${ProjDirPath}/../../../../../devices/MIMXRT1064/utilities
    ${ProjDirPath}/../../../../../components/phy/device/phyksz8081
    ${ProjDirPath}/../../../../../components/phy/mdio/enet
    ${ProjDirPath}/../../../../../middleware/eiq
    ${ProjDirPath}/../../../../../middleware/eiq/tensorflow-lite
    ${ProjDirPath}/../../../../../components/lists
    ${ProjDirPath}/../../../../../components/uart
    ${ProjDirPath}/../../../../../components/serial_manager
    ${ProjDirPath}/../../../../../devices/MIMXRT1064
    ${ProjDirPath}/../../../../../devices/MIMXRT1064/xip
    ${ProjDirPath}/../../../xip
    ${ProjDirPath}/../../../../../CMSIS/DSP
    ${ProjDirPath}/../../../../../CMSIS/Core/Include
    ${ProjDirPath}/../../../../../middleware/eiq/tensorflow-lite/third_party/cmsis
)

# include modules
include(middleware_lwip_apps_httpsrv_MIMXRT1064)

include(middleware_lwip_MIMXRT1064)

include(middleware_freertos-kernel_MIMXRT1064)

include(middleware_lwip_enet_ethernetif_MIMXRT1064)

include(driver_phy-common_MIMXRT1064)

include(driver_enet_MIMXRT1064)

include(utility_debug_console_MIMXRT1064)

include(middleware_lwip_empty_ethernetif_MIMXRT1064)

include(middleware_freertos-kernel_heap_3_MIMXRT1064)

include(driver_cache_armv7_m7_MIMXRT1064)

include(driver_phy-device-ksz8081_MIMXRT1064)

include(driver_mdio-enet_MIMXRT1064)

include(driver_gpt_MIMXRT1064)

include(middleware_eiq_deepviewrt_deps_json_MIMXRT1064)

include(middleware_eiq_deepviewrt_deps_stb_MIMXRT1064)

include(middleware_eiq_deepviewrt_deps_flatcc_MIMXRT1064)

include(middleware_eiq_tensorflow_lite_micro_cmsis_nn_MIMXRT1064)

include(middleware_eiq_deepviewrt_MIMXRT1064)

include(component_lists_MIMXRT1064)

include(component_lpuart_adapter_MIMXRT1064)

include(component_serial_manager_MIMXRT1064)

include(driver_common_MIMXRT1064)
include(driver_lpi2c_MIMXRT1064)


include(component_serial_manager_uart_MIMXRT1064)

include(driver_lpuart_MIMXRT1064)

include(device_MIMXRT1064_CMSIS_MIMXRT1064)

include(device_MIMXRT1064_startup_MIMXRT1064)

include(driver_clock_MIMXRT1064)

include(driver_igpio_MIMXRT1064)

include(driver_iomuxc_MIMXRT1064)

include(driver_xip_device_MIMXRT1064)

include(driver_xip_board_evkmimxrt1064_MIMXRT1064)

include(utility_assert_MIMXRT1064)

include(CMSIS_DSP_Library_MIMXRT1064)

include(middleware_freertos-kernel_extension_MIMXRT1064)

include(driver_mdio-common_MIMXRT1064)

include(CMSIS_Include_core_cm_MIMXRT1064)

include(middleware_eiq_tensorflow_lite_micro_MIMXRT1064)

include(middleware_eiq_tensorflow_lite_micro_third_party_flatbuffers_MIMXRT1064)

include(middleware_eiq_tensorflow_lite_micro_third_party_gemmlowp_MIMXRT1064)

include(middleware_eiq_tensorflow_lite_micro_third_party_ruy_MIMXRT1064)

include(middleware_eiq_tensorflow_lite_micro_third_party_cmsis_nn_MIMXRT1064)

include(device_MIMXRT1064_system_MIMXRT1064)

include(utilities_misc_utilities_MIMXRT1064)


TARGET_LINK_LIBRARIES(${MCUX_SDK_PROJECT_NAME} PRIVATE -Wl,--start-group)

target_link_libraries(${MCUX_SDK_PROJECT_NAME} PRIVATE m)

target_link_libraries(${MCUX_SDK_PROJECT_NAME} PRIVATE c)

target_link_libraries(${MCUX_SDK_PROJECT_NAME} PRIVATE gcc)

target_link_libraries(${MCUX_SDK_PROJECT_NAME} PRIVATE nosys)

if(CMAKE_BUILD_TYPE STREQUAL flexspi_nor_sdram_release)
    target_link_libraries(${MCUX_SDK_PROJECT_NAME} PRIVATE ${ProjDirPath}/../../../../../middleware/eiq/deepviewrt/lib/libdeepview-rt-cortex-m7f.a)
endif(CMAKE_BUILD_TYPE STREQUAL flexspi_nor_sdram_release)

if(CMAKE_BUILD_TYPE STREQUAL flexspi_nor_sdram_release)
    target_link_libraries(${MCUX_SDK_PROJECT_NAME} PRIVATE ${ProjDirPath}/../../../../../CMSIS/DSP/Lib/GCC/libarm_cortexM7lfdp_math.a)
endif(CMAKE_BUILD_TYPE STREQUAL flexspi_nor_sdram_release)

if(CMAKE_BUILD_TYPE STREQUAL flexspi_nor_sdram_debug)
    target_link_libraries(${MCUX_SDK_PROJECT_NAME} PRIVATE ${ProjDirPath}/../../../../../middleware/eiq/deepviewrt/lib/libdeepview-rt-cortex-m7f.a)
endif(CMAKE_BUILD_TYPE STREQUAL flexspi_nor_sdram_debug)

if(CMAKE_BUILD_TYPE STREQUAL flexspi_nor_sdram_debug)
    target_link_libraries(${MCUX_SDK_PROJECT_NAME} PRIVATE ${ProjDirPath}/../../../../../CMSIS/DSP/Lib/GCC/libarm_cortexM7lfdp_math.a)
endif(CMAKE_BUILD_TYPE STREQUAL flexspi_nor_sdram_debug)

TARGET_LINK_LIBRARIES(${MCUX_SDK_PROJECT_NAME} PRIVATE -Wl,--end-group)


