set(SRC_DIRS_LIST "." "mock_delegates")
set(INCLUDE_DIRS_LIST "." "mock_delegates")
set(ldfragments linker.lf)
# set(PRIV_REQUIRES_LIST device esp_matter esp_matter_console esp_matter_thread_br app_reset console fatfs hal)

# Add the electrical measurement directory to source and include paths
list(APPEND SRC_DIRS_LIST "electrical_measurement")
list(APPEND INCLUDE_DIRS_LIST "electrical_measurement")

if(CONFIG_IDF_TARGET_ESP32 OR CONFIG_IDF_TARGET_ESP32S3)
    list(APPEND SRC_DIRS_LIST "driver/fan")
    list(APPEND INCLUDE_DIRS_LIST "driver/fan/include")
endif()

if (CONFIG_ENABLE_ESP_DIAGNOSTICS_TRACE)
    list(APPEND PRIV_INCLUDE_DIRS_LIST "${MATTER_SDK_PATH}/examples/platform/esp32/diagnostics")
    list(APPEND SRC_DIRS_LIST "${MATTER_SDK_PATH}/examples/platform/esp32/diagnostics")
endif (CONFIG_ENABLE_ESP_DIAGNOSTICS_TRACE)

idf_component_register(SRC_DIRS          ${SRC_DIRS_LIST}
                      PRIV_INCLUDE_DIRS  "." "${ESP_MATTER_PATH}/examples/common/utils" ${PRIV_INCLUDE_DIRS_LIST}
                    #   PRIV_REQUIRES      ${PRIV_REQUIRES_LIST}
                      INCLUDE_DIRS       ${INCLUDE_DIRS_LIST}
                      LDFRAGMENTS        "${ldfragments}")

target_compile_options(${COMPONENT_LIB} PRIVATE "-DCHIP_HAVE_CONFIG_H")

if(CONFIG_IDF_TARGET_ESP32 OR CONFIG_IDF_TARGET_ESP32S3)
    idf_build_get_property(build_components BUILD_COMPONENTS)
    #To distinguish between a local component and a component manager
    if("espressif__esp_sensorless_bldc_control" IN_LIST build_components)
        idf_component_get_property(bldc_lib espressif__esp_sensorless_bldc_control COMPONENT_LIB)
    else()
        idf_component_get_property(bldc_lib esp_sensorless_bldc_control COMPONENT_LIB)
    endif()

    cmake_policy(SET CMP0079 NEW)
    target_link_libraries(${bldc_lib} PUBLIC ${COMPONENT_LIB})
endif()
