1# PICO_CMAKE_CONFIG: PICO_STDIO_UART, Option to globally enable stdio UART for all targets by default, type=bool, default=1, group=pico_stdlib 2option(PICO_STDIO_UART "Globally enable stdio UART" 1) 3# PICO_CMAKE_CONFIG: PICO_STDIO_USB, Option to globally enable stdio USB for all targets by default, type=bool, default=0, group=pico_stdlib 4option(PICO_STDIO_USB "Globally enable stdio USB" 0) 5# PICO_CMAKE_CONFIG: PICO_STDIO_SEMIHOSTING, Option to globally enable stdio semi-hosting for all targets by default, type=bool, default=0, group=pico_stdlib 6option(PICO_STDIO_SEMIHOSTING "Globally enable stdio semi-hosting" 0) 7# PICO_CMAKE_CONFIG: PICO_STDIO_RTT, Option to globally enable stdio RTT for all targets by default, type=bool, default=0, group=pico_stdlib 8option(PICO_STDIO_RTT "Globally enable stdio RTT" 0) 9 10if (NOT TARGET pico_stdio) 11 pico_add_library(pico_stdio) 12 13 target_include_directories(pico_stdio_headers SYSTEM INTERFACE ${CMAKE_CURRENT_LIST_DIR}/include) 14 15 target_sources(pico_stdio INTERFACE 16 ${CMAKE_CURRENT_LIST_DIR}/stdio.c 17 ) 18 19 pico_wrap_function(pico_stdio printf) # here not pico_printf as we do mutex 20 pico_wrap_function(pico_stdio vprintf) # here not pico_printf as we do mutex 21 pico_wrap_function(pico_stdio puts) 22 pico_wrap_function(pico_stdio putchar) 23 pico_wrap_function(pico_stdio getchar) 24 25 if (TARGET pico_printf) 26 pico_mirrored_target_link_libraries(pico_stdio INTERFACE pico_printf) 27 endif() 28 29 function(pico_enable_stdio_uart TARGET ENABLED) 30 set_target_properties(${TARGET} PROPERTIES PICO_TARGET_STDIO_UART ${ENABLED}) 31 endfunction() 32 33 function(pico_enable_stdio_usb TARGET ENABLED) 34 set_target_properties(${TARGET} PROPERTIES PICO_TARGET_STDIO_USB ${ENABLED}) 35 endfunction() 36 37 function(pico_enable_stdio_semihosting TARGET ENABLED) 38 set_target_properties(${TARGET} PROPERTIES PICO_TARGET_STDIO_SEMIHOSTING ${ENABLED}) 39 endfunction() 40 41 function(pico_enable_stdio_rtt TARGET ENABLED) 42 set_target_properties(${TARGET} PROPERTIES PICO_TARGET_STDIO_RTT ${ENABLED}) 43 endfunction() 44 45 if (TARGET pico_stdio_uart) 46 target_link_libraries(pico_stdio INTERFACE $<IF:$<BOOL:$<IF:$<STREQUAL:$<TARGET_PROPERTY:PICO_TARGET_STDIO_UART>,>,${PICO_STDIO_UART},$<TARGET_PROPERTY:PICO_TARGET_STDIO_UART>>>,pico_stdio_uart,>) 47 target_link_libraries(pico_stdio_headers INTERFACE $<IF:$<BOOL:$<IF:$<STREQUAL:$<TARGET_PROPERTY:PICO_TARGET_STDIO_UART>,>,${PICO_STDIO_UART},$<TARGET_PROPERTY:PICO_TARGET_STDIO_UART>>>,pico_stdio_uart_headers,>) 48 endif() 49 50 if (TARGET pico_stdio_usb) 51 target_link_libraries(pico_stdio INTERFACE $<IF:$<BOOL:$<IF:$<STREQUAL:$<TARGET_PROPERTY:PICO_TARGET_STDIO_USB>,>,${PICO_STDIO_USB},$<TARGET_PROPERTY:PICO_TARGET_STDIO_USB>>>,pico_stdio_usb,>) 52 target_link_libraries(pico_stdio_headers INTERFACE $<IF:$<BOOL:$<IF:$<STREQUAL:$<TARGET_PROPERTY:PICO_TARGET_STDIO_USB>,>,${PICO_STDIO_USB},$<TARGET_PROPERTY:PICO_TARGET_STDIO_USB>>>,pico_stdio_usb_headers,>) 53 endif() 54 55 if (TARGET pico_stdio_semihosting) 56 target_link_libraries(pico_stdio INTERFACE $<IF:$<BOOL:$<IF:$<STREQUAL:$<TARGET_PROPERTY:PICO_TARGET_STDIO_SEMIHOSTING>,>,${PICO_STDIO_SEMIHOSTING},$<TARGET_PROPERTY:PICO_TARGET_STDIO_SEMIHOSTING>>>,pico_stdio_semihosting,>) 57 target_link_libraries(pico_stdio_headers INTERFACE $<IF:$<BOOL:$<IF:$<STREQUAL:$<TARGET_PROPERTY:PICO_TARGET_STDIO_SEMIHOSTING>,>,${PICO_STDIO_SEMIHOSTING},$<TARGET_PROPERTY:PICO_TARGET_STDIO_SEMIHOSTING>>>,pico_stdio_semihosting_headers,>) 58 endif() 59 60 if (TARGET pico_stdio_rtt) 61 target_link_libraries(pico_stdio INTERFACE $<IF:$<BOOL:$<IF:$<STREQUAL:$<TARGET_PROPERTY:PICO_TARGET_STDIO_RTT>,>,${PICO_STDIO_RTT},$<TARGET_PROPERTY:PICO_TARGET_STDIO_RTT>>>,pico_stdio_rtt,>) 62 target_link_libraries(pico_stdio_headers INTERFACE $<IF:$<BOOL:$<IF:$<STREQUAL:$<TARGET_PROPERTY:PICO_TARGET_STDIO_RTT>,>,${PICO_STDIO_RTT},$<TARGET_PROPERTY:PICO_TARGET_STDIO_RTT>>>,pico_stdio_rtt_headers,>) 63 endif() 64 65endif()