How to include external library for my module dependency on ESP-IDF project?
12:56 07 Nov 2025

I'm new to C++, cmake and esp-idf coding. My code project is as per Expressif's structure. I found aC++ BLE library https://github.com/h2zero/esp-nimble-cpp/tree/master that I'd liketo include. Their instruction says to simply extract in component folder. So now my project structure looks like below:

- myProject/
        - CMakeLists.txt
        - sdkconfig
        - components/ - component1/ - CMakeLists.txt
                                    - Kconfig
                                    - src1.c
                      - component2/ - CMakeLists.txt
                                    - Kconfig
                                    - src1.c
                                    - include/ - component2.h
                      - esp-nimble-cpp-release-2.3/
                                    - CMakeLists.txt
                                    - Kconfig
                                    - src/
                                    - ... (other files and dirs included in esp-nimble-cpp)
        - main/       - CMakeLists.txt
                      - src1.c
                      - src2.c

        - build/

One of my component, say component2 depends on esp-nimble-cpp. On VSCode, I did add #include "NimBLEDevice.h" and it seems to find it. But any classes defined in esp-nimble-cpp are not defined.

I tried to add REQUIRES esp-nimble-cpp-release-2.3 on CMakeLists.txt on component2 (and variant of those) but it can't find it. Not sure what to do from here. Any help?

c++ cmake esp-idf