Hi everyone,
I’m developing a custom ESPHome component that works correctly on its own, but now I need to include a C++ library inside the component.
My folder structure looks like this:
esphome/components/
└── my_component/
├── __init__.py
├── my_component.cpp
├── my_component.h
└── library/
├── CMakeLists.txt
├── include/library/*.hpp
└── src/*.cpp
The problem is that the library/ folder isn’t copied into ESPHome’s build directory, and its CMakeLists.txt doesn’t seem to be executed.
The component compiles fine if I put everything directly under my_component/, but I’d like to keep the library as a proper submodule with its own CMake structure.
So far I’ve tried:
- Adding a
CMakeLists.txtinsidemy_component/withadd_subdirectory(library) - Including
target_include_directories()andtarget_sources()manually - Checking whether
__init__.pyneeds to reference it somehow
…but it seems that ESPHome ignores custom CMakeLists.txt inside components.
Is there a supported way to make ESPHome compile sources from a nested library/ folder with its own CMake file, or do I have to flatten the library into the component’s root?
Any guidance or examples would be greatly appreciated.