0

I have been using espidf and idf.py toolchain to compile a basic project template. It uses mainly CMake to build and the structure i want it is as following:

│   CMakeLists.txt
│   sdkconfig
├───components
│   ├───custom_foca
│   │   │   CMakeLists.txt
│   │   │   custom_foca.c
│   │   └───include
│   │           custom_foca.h
│   └───custom_foca2
│       │   CMakeLists.txt
│       │   custom_foca2.c
│       └───include
│               custom_foca2.h
├───include
│       defines.h
└───src
        CMakeLists.txt
        main.c

I created 2 custom components (libraries) in the "components" folder called "custom_foca" and "custom_foca2". The problem is that i don't want to call them individually in the INCLUDE_DIRS of the CMakeLists.txt on src folder, because of scalability issues.

file(GLOB_RECURSE srcs *.c)

set(include_dirs "."
                  "../include"
                  "../components/custom_foca/include"
                  "../components/custom_foca2/include")
# And it keeps going....

idf_component_register(
    SRCS "${srcs}"
    INCLUDE_DIRS "${include_dirs}"
)

The code is uploaded in Github on this link if you need more information.

I'm need a code that recursively adds every include folder from "components" directory into a variable, so i can add it into INCLUDE_DIRS on main sources.

Regards!

0 Answers0