cmake_minimum_required(VERSION 3.20)

set(BOARD "nanoch32v305")

# Use WCH GCC12 Toolchain 
#set(CMAKE_C_COMPILER "riscv-wch-elf-gcc")
#set(CMAKE_CXX_COMPILER "riscv-wch-elf-g++")
#set(CMAKE_ASM_COMPILER "riscv-wch-elf-gcc")

include(${CMAKE_CURRENT_SOURCE_DIR}/tinyusb/hw/bsp/family_support.cmake)

# gets PROJECT name for the example (e.g. <BOARD>-<DIR_NAME>)
family_get_project_name(PROJECT ${CMAKE_CURRENT_LIST_DIR})

project(${PROJECT} C CXX ASM)

# Checks this example is valid for the family and initializes the project
family_initialize_project(${PROJECT} ${CMAKE_CURRENT_LIST_DIR})

# Espressif has its own cmake build system
if(FAMILY STREQUAL "espressif")
  return()
endif()

add_executable(${PROJECT})

if (FORCE_READONLY)
target_compile_definitions(${PROJECT} PRIVATE
  CFG_EXAMPLE_VIDEO_READONLY
)
endif()

# Example source
target_sources(${PROJECT} PUBLIC
  ${CMAKE_CURRENT_SOURCE_DIR}/main.c
  ${CMAKE_CURRENT_SOURCE_DIR}/usb_descriptors.c
  ${CMAKE_CURRENT_SOURCE_DIR}/xgb_capture.c
)

# Example include
target_include_directories(${PROJECT} PUBLIC
  ${CMAKE_CURRENT_SOURCE_DIR}
)

# Configure compilation flags and libraries for the example without RTOS.
# See the corresponding function in hw/bsp/FAMILY/family.cmake for details.
family_configure_device_example(${PROJECT} noos)
