cmake_minimum_required(VERSION 3.22)
idf_build_get_property(target IDF_TARGET)

set(srcs "src/common/test_intr_utils.c"
         "src/common/test_panic_handler.c")

if(CONFIG_SOC_SUPPORT_TEE_SYS_APM_TEST)
    list(APPEND srcs "src/common/test_apm_utils.c"
                     "src/common/test_setup_utils.c"
                     "src/pms/test_tee_vectors.S")
    if(CONFIG_SOC_APM_CTRL_FILTER_SUPPORTED)
        list(APPEND srcs "src/pms/test_tee_sys_apm.c")
    else()
        list(APPEND srcs "src/pms/test_tee_pms.c")
    endif()
endif()

if(CONFIG_SOC_SUPPORT_TEE_MSPI_PMS_TEST)
    list(APPEND srcs "src/pms/test_mspi_pms.c")
endif()

if(CONFIG_SOC_SUPPORT_TEE_PERI_APM_TEST)
    list(APPEND srcs "src/pms/test_tee_peri_apm.c")
endif()

if(CONFIG_SOC_SUPPORT_TEE_INTR_TEST)
    list(APPEND srcs "src/cpu_intr/test_interrupt.c"
                     "src/cpu_intr/test_vectors_m.S"
                     "src/cpu_intr/test_vectors_u.S")
endif()

idf_component_register(SRCS "${srcs}"
                       INCLUDE_DIRS "include" "priv_include"
                       PRIV_INCLUDE_DIRS "priv_include/${target}"
                       REQUIRES ulp unity esp_hal_security
                       PRIV_REQUIRES bootloader_support esp_hal_timg esp_hw_support
                                     esp_mm esp_partition esp_psram spi_flash
                       LDFRAGMENTS linker.lf)

if(CONFIG_ULP_COPROC_ENABLED)
    set(ulp_app_name ulp_lp_core_${COMPONENT_NAME})
    set(ulp_rv_srcs "src/ulp/ulp_lp_core_main.c" "src/ulp/ulp_vectors.S")
    ulp_embed_binary(${ulp_app_name} "${ulp_rv_srcs}" "${ulp_exp_dep_srcs}")
endif()
