Page 1 of 1

Adding a library to CMakeList

Posted: Mon Dec 12, 2022 6:50 pm
by ArminArmin
Hi,

I have LVGL library:

Code: Select all

https://github.com/espressif/esp-iot-solution
In this path:

Code: Select all

c:/path/esp-iot-solution
I would like to add this path to my project.


What I did:
1. Created a new environment variable for the library path (c:/path/esp-iot-solution) called IOT_SOLUTION_PATH.
2. In the CMakeLists.txt of the project, I added:

Code: Select all

set(EXTRA_COMPONENT_DIRS "${EXTRA_COMPONENT_DIRS} ${IOT_SOLUTION_PATH}/components/button")
3. Include it:

Code: Select all

#include "iot_button.h"
After compiling:

Code: Select all

fatal error: #include "iot_button.h": No such file or directory

In general, even though I added the environment variable to the CMakeList.txt, the program still cannot get the related files.

What is the solution?

Thanks

Re: Adding a library to CMakeList

Posted: Tue Dec 13, 2022 4:30 pm
by ESP_igrr
Same as in the other topic, please check whether you have added the component (iot_button in this case) to the REQUIRES or PRIV_REQUIRES list of the component where you are trying to include the header file.

Note that for new projects, we recommend installing the components automatically using the IDF Component Manager, instead of manually downloading them and adding to CMake. You can find the components at https://components.espressif.com/ and install them using "idf.py add-dependency" command. Several example in ESP-IDF v5.0 are already using this approach.