Modifying env for just a single library, not the entire build

This is a question about modifying the env variable for a build.

Say one has a number of libraries (arranged in the lib folder). How does one change the build flag for ONLY a single library without affecting everything else? I’ve tried using a middleware script:

def target-lib_configuration(env, node):
      env.Append(CCFLAGS=["-Wno-error=maybe-uninitialized"])

env.AddBuildMiddleware(target-lib_configuration, "*/target-lib/*")

But this appears to effect the entire build, not just the target lib. It also seems cumulative, for each file that matches it appends the change.

Many thanks

I think the cpp build process can handle global compiler options.

Check out the documentation https://docs.platformio.org/en/latest/scripting/middlewares.html, it has a middleware extra_http_configuration which does filtering and I guess this is what you need.