target_include_directories(
    ${CMAKE_PROJECT_NAME}
    PUBLIC
    ${CMAKE_CURRENT_LIST_DIR}
)

get_property(include_dirs TARGET ${CMAKE_PROJECT_NAME} PROPERTY INCLUDE_DIRECTORIES)
# foreach(dir ${include_dirs})
#   message(STATUS "dir='${dir}'")
# endforeach()

set(EMBFMT_CPU_PARAMS ${cpu_PARAMS})
add_subdirectory(embfmt)

add_subdirectory(blocking_io)

# set(ETHERLIB_INCLUDES ${include_dirs})
# set(ETHERLIB_CPU_PARAMS ${cpu_PARAMS})
# add_subdirectory(etherlib)

# set(FLEXPTP_INCLUDES ${include_dirs})
# set(FLEXPTP_CPU_PARAMS ${cpu_PARAMS})
# add_subdirectory(flexptp)

# Add flatUSB
# set(FLATUSB_CLASSES CDC_ACM)
# set(FLATUSB_INCLUDES ${include_dirs})
# set(FLATUSB_CPU_PARAMS ${cpu_PARAMS})
# set(FLATUSB_COMPILE_DEFS ${comp_defs})
# set(FLATUSB_DESC_DIR ${CMAKE_CURRENT_LIST_DIR}/usb-descriptors)
# set(FLATUSB_DRIVER_SRC ${CMAKE_CURRENT_LIST_DIR}/flatUSB/driver/stm32/usb_drv.c)
# set(FLATUSB_DESC_JSON ${CMAKE_CURRENT_LIST_DIR}/usb-descriptors/usb_config_acm.json)
# add_subdirectory(flatUSB)

set(LWIP_DIR ${CMAKE_CURRENT_LIST_DIR}/lwip)
set(LWIP_PORT_DIR ${CMAKE_CURRENT_LIST_DIR}/lwip_port)
#set(LWIP_CONTRIB_DIR ${LWIP_DIR}/contrib)
set(LWIP_INCLUDE_DIRS
    ${LWIP_DIR}/src/include
    ${LWIP_DIR}/contrib
    ${LWIP_PORT_DIR}/arch
    ${LWIP_PORT_DIR}
    ${include_dirs}
)
message(${LWIP_PORT_DIR})
set(LWIP_COMPILER_FLAGS ${cpu_PARAMS})
include(${LWIP_DIR}/src/Filelists.cmake)
#include(${LWIP_DIR}/contrib/Filelists.cmake)

target_include_directories(${CMAKE_PROJECT_NAME} PUBLIC ${LWIP_DIR}/src/include ${LWIP_PORT_DIR})
#target_sources(lwipcore PUBLIC ${LWIP_PORT_DIR}/OS/sys_arch.c)
target_sources(${CMAKE_PROJECT_NAME} PUBLIC ${LWIP_PORT_DIR}/OS/sys_arch.c)

target_link_libraries(${CMAKE_PROJECT_NAME}
    # flatUSB
    # flexptp
    # etherlib
    embfmt
    lwipcore)
