Skip to content

Commit 9c7e31b

Browse files
committed
hello_world: fix build guards to allow host build, and improve missing tinyusb message
1 parent 396ca36 commit 9c7e31b

File tree

2 files changed

+18
-16
lines changed

2 files changed

+18
-16
lines changed

hello_world/CMakeLists.txt

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,2 @@
1-
if (NOT PICO_NO_HARDWARE)
2-
add_subdirectory(usb)
3-
add_subdirectory(serial)
4-
endif ()
1+
add_subdirectory(serial)
2+
add_subdirectory(usb)

hello_world/usb/CMakeLists.txt

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,20 @@
1-
add_executable(hello_usb
2-
hello_usb.c
3-
)
1+
if (TARGET tinyusb_device)
2+
add_executable(hello_usb
3+
hello_usb.c
4+
)
45

5-
# Pull in our pico_stdlib which aggregates commonly used features
6-
target_link_libraries(hello_usb pico_stdlib)
6+
# Pull in our pico_stdlib which aggregates commonly used features
7+
target_link_libraries(hello_usb pico_stdlib)
78

8-
# enable usb output, disable uart output
9-
pico_enable_stdio_usb(hello_usb 1)
10-
pico_enable_stdio_uart(hello_usb 0)
9+
# enable usb output, disable uart output
10+
pico_enable_stdio_usb(hello_usb 1)
11+
pico_enable_stdio_uart(hello_usb 0)
1112

12-
# create map/bin/hex/uf2 file etc.
13-
pico_add_extra_outputs(hello_usb)
13+
# create map/bin/hex/uf2 file etc.
14+
pico_add_extra_outputs(hello_usb)
1415

15-
# add url via pico_set_program_url
16-
example_auto_set_url(hello_usb)
16+
# add url via pico_set_program_url
17+
example_auto_set_url(hello_usb)
18+
elseif(PICO_ON_DEVICE)
19+
message(WARNING "not building hello_usb because TinyUSB submodule is not initialized in the SDK")
20+
endif()

0 commit comments

Comments
 (0)