mirror of
https://github.com/hathach/tinyusb.git
synced 2025-01-17 05:32:55 +08:00
95f2478146
- Examples should be CMake buildable from their own subdirectory; such a build will error out based on matching .skip.MCU_xxx or a mismatched .only.MCU_ - It should be possible to build from a higher level and use .skip.MCU_ and .only.MCU_ to filter which examples get built - The intention is for the CMakeLists.txts in the examples to be non family specific and without MCU based IFs. I have started this work, but am not really sure the state of the esp32 stuff; in any case the plan is to have everything encapsulated in the FAMILY/family.cmake - pico_examples now just includes examples/device/CMakeLists.txt and examples/host/CMakeLists.txt directly, as they also build correctly when included from there. Note that .skip.MCU_ for esp32 in the directories it wasn't previously avaiable has not been added, as the .skip is common to the regular Makefile builds also. It isn't clear whether these examples should build for esp32, but if not .skip should be added.
70 lines
2.1 KiB
CMake
70 lines
2.1 KiB
CMake
cmake_minimum_required(VERSION 3.13)
|
|
if (NOT TARGET _rp2040_family_inclusion_marker)
|
|
add_library(_rp2040_family_inclusion_marker INTERFACE)
|
|
|
|
# include basic family CMake functionality
|
|
set(FAMILY_MCUS RP2040 rp2040)
|
|
include(${CMAKE_CURRENT_LIST_DIR}/../family.cmake)
|
|
|
|
if (BOARD AND NOT PICO_BOARD)
|
|
message("Defaulting PICO_BOARD from BOARD ('${BOARD}')")
|
|
set(PICO_BOARD ${BOARD})
|
|
endif()
|
|
|
|
# add the SDK in case we are standalone tinyusb example (noop if already present)
|
|
include(${CMAKE_CURRENT_LIST_DIR}/pico_sdk_import.cmake)
|
|
set(BOARD ${PICO_BOARD})
|
|
|
|
# TOP is absolute path to root directory of TinyUSB git repo
|
|
set(TOP "../../..")
|
|
get_filename_component(TOP "${TOP}" REALPATH)
|
|
|
|
# tinyusb_additions will hold our extra settings libraries
|
|
add_library(tinyusb_additions INTERFACE)
|
|
|
|
target_compile_definitions(tinyusb_additions INTERFACE
|
|
PICO_RP2040_USB_DEVICE_ENUMERATION_FIX=1
|
|
)
|
|
|
|
if(DEFINED LOG)
|
|
target_compile_definitions(tinyusb_additions INTERFACE CFG_TUSB_DEBUG=${LOG} )
|
|
endif()
|
|
|
|
if(LOGGER STREQUAL "rtt")
|
|
target_compile_definitions(tinyusb_additions INTERFACE
|
|
LOGGER_RTT
|
|
SEGGER_RTT_MODE_DEFAULT=SEGGER_RTT_MODE_BLOCK_IF_FIFO_FULL
|
|
)
|
|
|
|
target_sources(tinyusb_additions INTERFACE
|
|
${TOP}/lib/SEGGER_RTT/RTT/SEGGER_RTT.c
|
|
)
|
|
|
|
target_include_directories(tinyusb_additions INTERFACE
|
|
${TOP}/lib/SEGGER_RTT/RTT
|
|
)
|
|
endif()
|
|
|
|
function(family_configure_target TARGET)
|
|
pico_add_extra_outputs(${TARGET})
|
|
pico_enable_stdio_uart(${TARGET} 1)
|
|
target_link_libraries(${TARGET} PUBLIC pico_stdlib pico_bootsel_via_double_reset tinyusb_board tinyusb_additions)
|
|
endfunction()
|
|
|
|
function(family_configure_device_example TARGET)
|
|
family_configure_target(${TARGET})
|
|
target_link_libraries(${TARGET} PUBLIC pico_stdlib tinyusb_device)
|
|
endfunction()
|
|
|
|
function(family_configure_host_example TARGET)
|
|
family_configure_target(${TARGET})
|
|
target_link_libraries(${TARGET} PUBLIC pico_stdlib tinyusb_host)
|
|
endfunction()
|
|
|
|
function(family_initialize_project PROJECT DIR)
|
|
_family_initialize_project(${PROJECT} ${DIR})
|
|
enable_language(C CXX ASM)
|
|
pico_sdk_init()
|
|
endfunction()
|
|
endif()
|