diff --git a/examples/peripherals/usb/host/cdc/common/cdc_acm_host/CMakeLists.txt b/examples/peripherals/usb/host/cdc/common/cdc_acm_host/CMakeLists.txt index 39bec48e25..f2ff73f8fc 100644 --- a/examples/peripherals/usb/host/cdc/common/cdc_acm_host/CMakeLists.txt +++ b/examples/peripherals/usb/host/cdc/common/cdc_acm_host/CMakeLists.txt @@ -1,3 +1,15 @@ -idf_component_register(SRCS "cdc_acm_host.c" - INCLUDE_DIRS "include" - REQUIRES usb) +set(srcs) +set(include) +# As CONFIG_USB_OTG_SUPPORTED comes from Kconfig, it is not evaluated yet +# when components are being registered. +set(require usb) + +if(CONFIG_USB_OTG_SUPPORTED) + list(APPEND srcs "cdc_acm_host.c") + list(APPEND include "include") +endif() + +idf_component_register(SRCS ${srcs} + INCLUDE_DIRS ${include} + REQUIRES ${require} + )