Page 1 of 1

Arduino as a component with idf as lib

Posted: Thu Dec 01, 2022 3:26 pm
by majsman
Hi all,

I have a large, quite complex codebase for the ESP32 that is based on Arduino and I'm trying to migrate away from platformio since it doesn't allow the flexibility that I need.

I have setup the project as a regular cmake project with the idf as a lib (following the general concepts here: https://github.com/espressif/esp-idf/tr ... idf_as_lib. I would ideally like to do it this way as, again, it lets me control

I have now got to the part where I need to include Arduino as a component, following the instructions here: https://docs.espressif.com/projects/ard ... onent.html. The issue is that the CMakeLists.txt in the Arduino component expects to be called from a registered component directory:

Code: Select all

CMake Error at /home/user/esp/esp-idf/tools/cmake/component.cmake:431 (message):
  Called idf_component_register from a non-component directory.
Call Stack (most recent call first):
  components/arduino/CMakeLists.txt:211 (idf_component_register)
 
I think I have two options, either re-write the Arduino CMakeLists.txt and have to maintain it (a bit annoying) or, try to make the Arduino CMakeLists.txt think that everything is fine and pass everything required into it while still just using the rest as vanilla CMake. I think the second option is a bit easier though, does anyone have any resources that can explain how to do this?

Thanks in advance

Re: Arduino as a component with idf as lib

Posted: Tue Dec 06, 2022 2:01 pm
by gtjoseph
Do you really need to go down the idf-as-lib route? I'd think moving your current stuff into a regular esp-idf project and adding the ESP Arduino Core as a regular component would be the easiest route. That's what I did when moving from platformio.

Re: Arduino as a component with idf as lib

Posted: Tue Dec 06, 2022 3:48 pm
by ESP_igrr
Hi majsman,

Could you please post more details about how you have set up the project? If you could upload some simple example which shows this issue it would probably be the best option. Otherwise, please attach your project CMakeLists.txt file and show your project structure.