cmake_minimum_required(VERSION 3.13)

include(pico_sdk_import.cmake)

project(host_cdc_msc_hid C CXX ASM)
set(CMAKE_C_STNDARD 11)
set(CMAKE_CXX_STANDARD 17)
set(PICO_EXAMPLES_PATH ${PROJECT_SOURCE_DIR})

pico_sdk_init()


add_executable(host_cdc_msc_hid)

# Example source
target_sources(host_cdc_msc_hid PUBLIC
        hid_app.c
        main.c
        msc_app.c
        cdc_app.c
        diskio_USB.c
        lib/FatFs/source/ff.c
        lib/FatFs/source/ffsystem.c
        lib/FatFs/source/diskio.c
        )

# Make sure TinyUSB can find tusb_config.h
target_include_directories(host_cdc_msc_hid PUBLIC
        ${CMAKE_CURRENT_LIST_DIR}
        ${CMAKE_CURRENT_LIST_DIR}/lib/FatFs/source/)

# In addition to pico_stdlib required for common PicoSDK functionality, add dependency on tinyusb_host
# for TinyUSB device support and tinyusb_board for the additional board support library used by the example
target_link_libraries(host_cdc_msc_hid PUBLIC pico_stdlib tinyusb_host tinyusb_board)

pico_add_extra_outputs(host_cdc_msc_hid)


add_custom_target(Flash
    DEPENDS host_cdc_msc_hid
    COMMAND sudo picotool load -f ${PROJECT_BINARY_DIR}/host_cdc_msc_hid.uf2
)
