Adding a library to CMakeList

ArminArmin
Posts: 9
Joined: Mon Aug 08, 2022 6:14 pm

Adding a library to CMakeList

Postby ArminArmin » Mon Dec 12, 2022 6:50 pm

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
Last edited by ArminArmin on Tue Dec 20, 2022 2:36 pm, edited 1 time in total.

ESP_igrr
Posts: 2072
Joined: Tue Dec 01, 2015 8:37 am

Re: Adding a library to CMakeList

Postby ESP_igrr » Tue Dec 13, 2022 4:30 pm

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.

Who is online

Users browsing this forum: Apostal2008, jgrossholtz, kapucin22, Majestic-12 [Bot], MicroController, niels.1234 and 141 guests