How to Properly Use Src_Dirs Parameter in Idf_Component_Register Function in Esp-Idf?

I'm new to ESP-IDF and Platformio.

I want to add my source files in CMakeLists.txt by folders, not one by one as files. This should be done by SRC_DIRS but it doesn't work for me. How can I get it done?

8

1 Answer

So I think I figured it out. In the docs

idf_component_register([[SRCS src1 src2 ...] | [[SRC_DIRS dir1 dir2 ...] [EXCLUDE_SRCS src1 src2 ...]]

notice the "OR" bar between SRCS and SRC_DIRS. This made me think that I can either use either SRCS or SRC_DIRS, but not both at the same time. So following works

idf_component_register(SRC_DIRS "." "uart")

Notice, however, as @Tarmo noticed, that you have to run reconfigure or clean build each time you add a new source.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Chloe Bennett

Chloe Bennett

Culture, Media & Entertainment Columnist

Chloe Bennett explores the intersection of pop culture, streaming entertainment, digital trends, and contemporary lifestyle. Her weekly commentary reaches thousands of culture enthusiasts.

Share this article
Twitter Facebook Pinterest