Can't include header from library while using ESP-IDF framework

I’m trying to use the Embedded Template Library, and include some of it’s headers in my project. I’ve included it in my platformio.ini file as prescribed in the documentation:

[platformio]
src_dir = main
build_cache_dir = .pio/build_cache

[env]
platform = espressif32
framework = espidf
monitor_speed = 115200
debug_tool = esp-builtin
;enable this if you wanna upload over JTAG 
;upload_protocol = esp-builtin
build_type = debug
build_flags = -DCORE_DEBUG_LEVEL=5 ;-v
lib_compat_mode = off
lib_deps = 
            Embedded Template Library@^20.39.4

[env:esp32-s3-devkitm-1]
board = esp32-s3-devkitm-1

I’m using the esp-idf framework so my project structure is setup around the Cmake modules where each module has a CMakeLists.txt file. From within one of my modules in one of the .hpp files I try to include one of the headers as described in the documentation:

#include "etl/queue.h"

The file is found and the C/C++ extension in VSCode seems to recognize it as part of my include path as i can control+click on it to open the file just fine and I get no linter warnings. However when I try to build

fatal error: etl/queue.h: No such file or directory
    6 | #include "etl/queue.h"

It can’t seem to find the file. I have never encounter this before with PIO but this might have something to do with the ESP-IDF framework having it’s own build system on top of the standard PIO build system and there might be something I need to do with my CMakeLists.txt files to make it work but I’m not sure what.

Any guidance would be appreciated

Hi @yamaan93, I’ve just tried a simple example with this library and it compiled without any errors. Could you provide a minimal example to reproduce the issue?

I was able to get it to work but with the added extra step of adding this to my main CMakeLists.txt:

# Add the ETL library from PlatformIO's libdeps folder
set(ETL_LIB_PATH "${CMAKE_SOURCE_DIR}/.pio/libdeps/esp32-s3-devkitm-1/Embedded Template Library/include")
# Add ETL to the global include directories
include_directories("${ETL_LIB_PATH}")

To reproduce, you need a project setup with the esp-idf “folder structure” instead of the standard pio structure. For me that looks something like this:

Component1
    |-- CMakeLists.txt
    |-- main.cpp
Component2
    |-- CMakeLists.txt
    |-- CAN.hpp
    |-- CAN.cpp
CMakeLists.txt
platformio.ini

if you try to include the headers in either of the components, it won’t work unless you modify your CMakeLists (either the global one or the ones in the components) to include the library directories you add.

I’m not a super big fan of the way I did it because I would need to modify this based on each of my configurations

Thanks for providing the project description, but to effectively reproduce the issue, I still need a working project example. Even seemingly small details in your build scripts can make a significant difference in debugging or understanding the context

Easiest thing is to just give you the repository at the commit before I found the work around: