Change CMakeLists.txt in order to compile with ESP-IDF

What do you want to achieve?

I am using SquareLine studio together with an eclipse project with esp-idf, the problem is that every time I export the ui files I have to change the last line of the CMakeLists.txt file to be able to compile the project correctly.
This is the change I make:
Remove: add_library(ui ${SOURCES})
Add: idf_component_register(SRCS "${SOURCES}")

Do you see alternative options and workaround to achieve it?

Mention some use cases

I think everyone using esp-idf (esp32) needs this

1 Like

ESP-IDF (and Espressif-IDE or Eclipse with Espressif plugin) relies on CMake and CMakeLists.txt files. So if for example you have your exported UI sources in the ā€˜main/uiā€™ folder inside the project folder, as is usually with ESP-IDF projects, you can recursively register the UI source files by these lines in a CMakeLists.txt file:
file(GLOB_RECURSE_SRC_UI ${CMAKE_SOURCE_DIR} "ui/*.c")
idf_component_register( SRCS "main.c" ${LV_UI_SOURCES} INCLUDE_DIRS "." "ui" )
(At least this is the way it is done by Espressif board-templates when you create a new Espressif project. The IDF-specific config is not written into the UI files, keeping the export platform-independent.)
I hope this information is useful for you but I donā€™t know much about your particular CMake configuration or error message to give more sophisticated tips.

1 Like

Hi Hermit, thanks . Iā€™m now using the generated file ā€œfilelist.txtā€ to include all the source files and I dont need to change the CMakeLists.txt manually anymore.

1 Like