Lib header include puzzle

This may be somewhat related to PIO library doesn't see header files in project's include folder and Including "global" Header File to private Libraries, but with a subtle difference.

My project needs to build for many platforms & frameworks, and has almost all its code placed in separate libs, which live in lib/foo/, lib/bar/, etc. The approach I found to work very nicely, is to have only the main app in src/, and to furthermore have separate versions, e.g. src/native-main.cpp, src/stm32cube-main.cpp. I then adjust the env for each build using src_filter = +<native-*>, etc. Each main is different, and pulls in just the right libs it needs. So far, so (very) good.

The puzzle is that some of these libs are hardware-specific drivers. A systick module for example, for which the implementation can be very different across platforms and frameworks. I can solve this with lots of #define settings in each driver, but would very much prefer to have an arch.h platform-specific header, so that the driver can just include arch.h, take advantage of some of the wrapper code in there, and figure out how to do the remaining super-platform-specific stuff via define’s.

But code in lib/*/ does not see files in include/ or src/, and rightly so, I think.

The question is, how can I add a path which the libraries do see, which has that specific arch.h header etc. It might seem that -I arch/stm32cube/ could do the trick, but if I use that approach, and set it in build_flags, then it becomes hard to use build_flags for other build-specific settings. As I understand it, PIO does not support a make-like build_flags += ... mechanism.

Am I missing the point and looking in the wrong direction for a solution?