I am working on integrating a 3rd party project into my application (LittleFS to be precise). I am attempting to compile the project as a static library then link this into my application. I have no problem with linking and getting the include paths correct, my problem is in how to handle the compile-time configuration.
For example, the project has a line like the following in its header:
struct lfs_config {
...
#ifdef LFS_THREADSAFE
int (*lock)(const struct lfs_config *c);
int (*unlock)(const struct lfs_config *c);
#endif
...
};
I would compile the 3rd party project/static library with the following flag to enable this feature:
gcc ... -DLFS_THREADSAFE
However, when I link this library into my application, for this to work, I need to also make sure that my application has the -DLFS_THREADSAFE flag set.
This means that I have to keep track of which defines are set in two separate places which seems like it will get a bit error-prone and cumbersome after a while.
My question is, how can I ensure that static library and application share the same configuration?