Page 1 of 1

Managing library includes in esp-idf components

Posted: Wed Dec 10, 2025 2:33 am
by ujurmsde
I have a library with many files that needs to be include. There are folders inside a main folder.

Now, I know that with custom components one can do this but not sure how to do this when I have multiple files spread across in many folders.

Is there some examples to show this scenario?

Re: Managing library includes in esp-idf components

Posted: Wed Dec 10, 2025 9:21 am
by MicroController
https://docs.espressif.com/projects/esp ... ists-files

You create a directory for your component/library with all the sources and header files in it. In that component directory you also create a component CMakeLists.txt file with a call to idf_component_register(...) in it.
In the arguments to idf_component_register() you specify the source files to be compiled (SRCS), any/all include directories where component-internal header files are located (PRIV_INCLUDE_DIRS), and any/all directories where the header files reside which other components should be able to include/use (INCLUDE_DIRS).