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

# 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}/build/${CMAKE_BUILD_TYPE})
SET(LIBRARY_OUTPUT_PATH ${ProjDirPath}/build/${CMAKE_BUILD_TYPE})

project(rt1050_freertos_usb)

set(MCUX_SDK_PROJECT_NAME rt1050_freertos_usb.elf)

include(${ProjDirPath}/flags.cmake)

include(${ProjDirPath}/config.cmake)

add_executable(${MCUX_SDK_PROJECT_NAME}
    "${ProjDirPath}/board/board.c"
    "${ProjDirPath}/board/board.h"
    "${ProjDirPath}/board/clock_config.c"
    "${ProjDirPath}/board/clock_config.h"
    "${ProjDirPath}/board/peripherals.c"
    "${ProjDirPath}/board/peripherals.h"
    "${ProjDirPath}/board/dcd.c"
    "${ProjDirPath}/board/dcd.h"
    "${ProjDirPath}/board/pin_mux.c"
    "${ProjDirPath}/board/pin_mux.h"
    "${ProjDirPath}/source/FreeRTOSConfig.h"
    "${ProjDirPath}/source/freertos_hello.c"
    "${ProjDirPath}/source/usb_application.c"
    "${ProjDirPath}/source/usb_application.h"
    "${ProjDirPath}/source/generated/usb_device_composite.c"
    "${ProjDirPath}/source/generated/usb_device_composite.h"
    "${ProjDirPath}/source/generated/usb_device_descriptor.c"
    "${ProjDirPath}/source/generated/usb_device_descriptor.h"
    "${ProjDirPath}/source/generated/usb_device_config.h"
)

target_include_directories(${MCUX_SDK_PROJECT_NAME} PRIVATE
    ${ProjDirPath}/board
    ${ProjDirPath}/source
    ${ProjDirPath}/source/generated
)

set(CMAKE_MODULE_PATH
    ${ProjDirPath}/
    ${ProjDirPath}/CMSIS
    ${ProjDirPath}/component/lists
    ${ProjDirPath}/component/serial_manager
    ${ProjDirPath}/component/uart
    ${ProjDirPath}/component/osa
    ${ProjDirPath}/device
    ${ProjDirPath}/drivers
    ${ProjDirPath}/freertos
    ${ProjDirPath}/startup
    ${ProjDirPath}/utilities
    ${ProjDirPath}/xip
    ${ProjDirPath}/middleware/usb
)

# include modules
include(driver_clock_MIMXRT1052)

include(middleware_freertos-kernel_heap_4_MIMXRT1052)

include(driver_common_MIMXRT1052)

include(device_MIMXRT1052_CMSIS_MIMXRT1052)

include(utility_debug_console_MIMXRT1052)

include(component_lpuart_adapter_MIMXRT1052)

include(component_serial_manager_MIMXRT1052)

include(component_lists_MIMXRT1052)

include(component_serial_manager_uart_MIMXRT1052)

include(driver_lpuart_MIMXRT1052)

include(device_MIMXRT1052_startup_MIMXRT1052)

include(driver_iomuxc_MIMXRT1052)

include(utility_assert_MIMXRT1052)

include(driver_igpio_MIMXRT1052)

include(driver_xip_device_MIMXRT1052)

include(driver_xip_board_MIMXRT1052)

include(middleware_freertos-kernel_MIMXRT1052)

include(middleware_freertos-kernel_extension_MIMXRT1052)

include(utilities_misc_utilities_MIMXRT1052)

include(CMSIS_Include_core_cm7_MIMXRT1052)

include(CMSIS_Include_common_MIMXRT1052)

include(CMSIS_Include_dsp_MIMXRT1052)

include(device_MIMXRT1052_system_MIMXRT1052)

include(middleware_usb_common_header_MIMXRT1052)

include(middleware_usb_device_common_header_MIMXRT1052)

include(middleware_usb_device_ehci_MIMXRT1052)
 
include(middleware_usb_phy_MIMXRT1052)

include(middleware_usb_device_controller_driver_MIMXRT1052)

include(middleware_usb_device_cdc_external_MIMXRT1052)
 
include(component_osa_MIMXRT1052)


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)

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


