Using build.srcFilter in library.json not working?

I’m trying to exclude the main.cpp file from the build of a library. This file is only usefull when the library is build as a project isself and is used for testing purposes. But when the library is build as part of another project I dont want the main.cpp compiled as it contains some hardware specific code, not needed when the library is deployed on other hardware.

I’ve tried adding a srcFilter to the build section of the library.json, but whatever I try, the main.cpp still gets compiled which results in errors.

Does anybody have a working example in Windows of using this?

Things I tried are i.e.:

    "build": {
    "flags": "-Wno-unused-function",
    "srcFilter": [

Found the solution
In contrary with what the documentation says, the srcFilter paths are not releative to the library root folder, but relative to the library src folder.

This works:

    "srcFilter": [
1 Like