In C/C++, each
.cpp file is compiled separately from all other
.cpp. Header files are shared but only if they are directly or indirectly included in all relevant
In your case, you are dealing with a library that you don’t want to modify. So you cannot include an additional header file. So build flags are the right way to go.
The situation is different if the library has a built-in configuration system that is designed to include a modifiable header file. The ESP-IDF framework has such an approach that extends to all libraries built for the framework. It even comes with a simple graphical tool for configuring the possible values. It has its share of disadvantages however.
In my experience, build flags are simple, straightforward and well integrated into PlatformIO. As long as their number is moderate, it’s my preferred solution.