Library Files in Subdirectories Not Exposed to Sketch

Hello,

I'm developing an Arduino library, but I'm having trouble including header files located in subdirectories under the src folder. If I place a file directly in src/, I can include other files from subdirectories using #include <>, but those files are not accessible from the user's sketch.

I have a library.properties file, and my directory structure is as follows (simplified for clarity):

MIDILAR
│   library.properties
│   readme.md
│
├── examples
│   ├── BuildTest
│   │   ├── BuildTest.cpp
│   │   └── CMakeLists.txt
│
├── src
│   │   MIDILAR.h
│   │   MidiProtocol.h
│   │
│   ├── AudioFoundation
│   │   ├── LUT
│   │   │   ├── BaseLUT.h
│   │   │   ├── LogExpLUT.h
│   │   │   └── SineLUT.h
│
└── tests
    ├── SystemFoundation
    │   ├── Clock
    │   │   ├── SystemFoundation_Clock.cc

library.properties :

name=MIDILAR
version=1.0.0
author=José Manuel Romo Peredo <josemanuel.romo.96@gmail.com>
maintainer=José Manuel Romo Peredo <josemanuel.romo.96@gmail.com>
sentence=A cross-platform Midi Processes library for unified development.
paragraph=CPSTL is a versatile library that provides a consistent interface for Uart Midi Ports, allowing developers to write cross-platform code that works seamlessly across different environments, with or without the C++ Standard Template Library.
category=Utilities
url=https://github.com/ChecheRomo96/MIDILAR
architectures=*
includes=
depends=
ldflags=

Issues I'm Facing:

  1. Header files inside src/AudioFoundation/LUT/ are not visible to the Arduino sketch.
  2. If I move a header file to src/, it becomes accessible.
  3. Files within subdirectories can include each other using #include <>, but they are not accessible from the sketch.

Questions:

  1. Is there a way to expose header files from subdirectories to the Arduino sketch?
  2. Do I need to modify the library.properties file or structure my library differently?

How I spotted this issue:

I started by creating an empty Arduino sketch and attempted to include:

#include <AudioFoundation/LUT/BaseLUT.h>

However, the compiler reported that the file could not be found. To investigate further, I replaced the include statement with:

#include <MIDILAR.h>

This successfully compiled, as MIDILAR.h includes all the relevant submodules. To further isolate the issue, I changed the include statement again to:

#include <MIDILAR_AudioFoundation.h>

This also compiled without issues. Since MIDILAR_AudioFoundation.h is inside the src subdir, and included by MIDILAR.h, this file itself includes AudioFoundation/LUT/BaseLUT.h, I concluded that only files located in the root of the src/ directory are directly visible to the sketch.

Any insights would be greatly appreciated!

The excerpt from the Library specification (emphasis mine) should answer your questions:

Only the src folder is added to the include search path (both when compiling the sketch and the library). When the user imports a library into their sketch (from the Arduino IDE's "Sketch > Include Library" menu or the Arduino Web Editor's "Include" button), the default behavior (configurable via the library.properties includes field) is for an #include statement to be added for all header (.h) files in the src/ directory (but not its subfolders). As a result, these header files form something of a de facto interface to your library; in general, the only header files in the root src/ folder should be those that you want to expose to the user's sketch and plan to maintain compatibility with in future versions of the library. Place internal header files in a subfolder of the src/ folder.

TL;DR: only the include files in your src directory are visible to the sketch.

I get that, but is there no way around that, like adding src to search paths or changing any configuration on the library.properties?

I believe the above speaks for itself.

Feel free to have a go at at altering the arduino-cli tool to meet your desires. I believe all the source code is open source.