From 9c7e31b8e700e1137b49aeb643d03d37a58bed93 Mon Sep 17 00:00:00 2001 From: graham sanderson Date: Sun, 28 Feb 2021 09:02:37 -0600 Subject: [PATCH] hello_world: fix build guards to allow host build, and improve missing tinyusb message --- hello_world/CMakeLists.txt | 6 ++---- hello_world/usb/CMakeLists.txt | 28 ++++++++++++++++------------ 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/hello_world/CMakeLists.txt b/hello_world/CMakeLists.txt index ca3f6a5..b1e0a1a 100644 --- a/hello_world/CMakeLists.txt +++ b/hello_world/CMakeLists.txt @@ -1,4 +1,2 @@ -if (NOT PICO_NO_HARDWARE) - add_subdirectory(usb) - add_subdirectory(serial) -endif () +add_subdirectory(serial) +add_subdirectory(usb) diff --git a/hello_world/usb/CMakeLists.txt b/hello_world/usb/CMakeLists.txt index dbe031a..7368c3d 100644 --- a/hello_world/usb/CMakeLists.txt +++ b/hello_world/usb/CMakeLists.txt @@ -1,16 +1,20 @@ -add_executable(hello_usb - hello_usb.c - ) +if (TARGET tinyusb_device) + add_executable(hello_usb + hello_usb.c + ) -# Pull in our pico_stdlib which aggregates commonly used features -target_link_libraries(hello_usb pico_stdlib) + # Pull in our pico_stdlib which aggregates commonly used features + target_link_libraries(hello_usb pico_stdlib) -# enable usb output, disable uart output -pico_enable_stdio_usb(hello_usb 1) -pico_enable_stdio_uart(hello_usb 0) + # enable usb output, disable uart output + pico_enable_stdio_usb(hello_usb 1) + pico_enable_stdio_uart(hello_usb 0) -# create map/bin/hex/uf2 file etc. -pico_add_extra_outputs(hello_usb) + # create map/bin/hex/uf2 file etc. + pico_add_extra_outputs(hello_usb) -# add url via pico_set_program_url -example_auto_set_url(hello_usb) + # add url via pico_set_program_url + example_auto_set_url(hello_usb) +elseif(PICO_ON_DEVICE) + message(WARNING "not building hello_usb because TinyUSB submodule is not initialized in the SDK") +endif()