I'm working on Tensorflow for microcontrollers and the same C++ source is used to build for (among others) Linux as well as Arduino.
I would like to use #ifdefs to separate out the platform specific code.
For example:
void my_function() {
... // common code to both Arduino and Linux
#ifdef MICRO_BUILD // embedded target
... // Arduino-specific implementation.
#else // Linux
... // More general implementation, with say dynamic memory allocation or Linux-only matrix math libraries.
#endif
... // common code to both Arduino and Linux
}
This pattern works fine with the arduino-cli:
arduino-cli compile --build-properties compiler.cpp.extra_flags=-DMICRO_BUILD
However, I can not figure out how to specify -DMICRO_BUILD for the Tensorflow Arduino library when it is built via the Arduino IDE as part of a sketch.
Is there a way to specify some custom cflags for a library? Maybe something similar to the ldflags that can be specified in library.properties so that any sketch that uses the Tensorflow Arduino library will build that library with -DMICRO_BUILD?