LDF does not find headers from projects in top level lib folder

Hi PIO Community!

I’ve been trying to get some local libraries to work and found a weird issue with the LDF. The issue, and how to reproduce it, is described perfectly on Github. I tried this on MacOS and on Linux and both did not work. If I recall right, it used to work in earlier versions of PIO, but it’s been a while since I used PIO.
My goal is to have a local library in lib and use these headers and sources in my main project (same project directory). If I am not mistaken, this should be exactly the purpose for this. I have also added the library name to lib_deps.

This error is reproducible for me (although you should rename main.cpp to main.c since ESP-IDF is a C framework…)

At least for PIO my Linux OS it doesn’t seem to be able to generate the right include flags for a library put in lib.

Following the docs you can however restructure it to a component, by structuring it as such

$ tree
├── CMakeLists.txt
├── components
│   └── mylib
│       ├── CMakeLists.txt
│       ├── mylib.c
│       └── mylib.h
├── include
│   └── README
├── lib
│   └── README
├── platformio.ini
├── sdkconfig
├── src
│   ├── CMakeLists.txt
│   └── main.c
└── test
    └── README

Where mylib/CMakeLists.txt is

idf_component_register(SRCS "mylib.c"
                       INCLUDE_DIRS ".")

and that compiles. But as I said, that looks like a core bug (especially if it magically works on Windows), so the github issue is valid for Linux.