# Copyright 2025 NXP
# All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
include(${SdkRootDirPath}/arch/arm/target/ram.cmake)
include(${SdkRootDirPath}/arch/arm/target/flexspi_nor.cmake)
include(${SdkRootDirPath}/arch/arm/target/flexspi_nor_sdram.cmake)
include(${SdkRootDirPath}/arch/arm/target/sdram.cmake)
include(${SdkRootDirPath}/arch/arm/target/sdram_txt.cmake)
include(${SdkRootDirPath}/examples/_common/project_setting/RT1xxx.cmake)
include(${CMAKE_CURRENT_LIST_DIR}/${core_id}/setting.cmake OPTIONAL)

if (CONFIG_MCUX_PRJSEG_module.board.suite)
    mcux_add_configuration(
        TARGETS sdram_debug              sdram_release
                flexspi_nor_sdram_debug  flexspi_nor_sdram_release
                sdram_txt_debug          sdram_txt_release
        CC "-DSKIP_SYSCLK_INIT=1"
    )

    mcux_add_configuration(
        TARGETS sdram_debug              sdram_release
                flexspi_nor_sdram_debug  flexspi_nor_sdram_release
                sdram_txt_debug          sdram_txt_release
        CC "-DDATA_SECTION_IS_CACHEABLE=1"
    )

    mcux_add_iar_configuration(
        TARGETS flexspi_nor_debug        flexspi_nor_release
                flexspi_nor_sdram_debug  flexspi_nor_sdram_release
        LD "--config_def=__use_flash64MB__=1"
    )

    mcux_add_mdk_configuration(
        TARGETS flexspi_nor_debug        flexspi_nor_release
                flexspi_nor_sdram_debug  flexspi_nor_sdram_release
        LD "--predefine=\"-D__use_flash64MB__=1\""
    )

    mcux_add_armgcc_configuration(
        TARGETS flexspi_nor_debug        flexspi_nor_release
                flexspi_nor_sdram_debug  flexspi_nor_sdram_release
        LD "-Xlinker --defsym=__use_flash64MB__=1"
    )

endif()

## Custom board modules
if(CONFIG_MCUX_PRJSEG_module.custom_board.boardfile)
    mcux_add_source(SOURCES board.h board.c)
    mcux_add_include(INCLUDES .)
endif()

if(CONFIG_MCUX_PRJSEG_module.custom_board.clock)
    mcux_add_source(SOURCES clock_config.h clock_config.c)
    mcux_add_include(INCLUDES .)
endif()

if(CONFIG_MCUX_PRJSEG_module.custom_board.pinmux)
    mcux_add_source(
      SOURCES
        pin_mux.h
        pin_mux.c
    )
    mcux_add_include(INCLUDES .)
endif()

## Custom board project hardware_init.c/app.h
# Use PROJECT_NAME to distinguish between different projects
if(CONFIG_MCUX_PRJSEG_project.custom_board.hw_app)
  mcux_add_source(
    SOURCES examples/${PROJECT_NAME}/${core_id}/hardware_init.c
            examples/${PROJECT_NAME}/${core_id}/app.h
  )
  mcux_add_include(INCLUDES examples/${PROJECT_NAME}/${core_id})
endif()