Need help excluding a cpp in a library from compiling


I try to modify an existing library to be able to use it with platformio. The problem, is that library have a unitTests folder with a main.cpp file. When I compile my application, the compiler try to build the unitTests also.

Here a simple platformio.ini

    ; PlatformIO Project Configuration File
;   Build options: build flags, source filter
;   Upload options: custom upload port, speed and extra flags
;   Library options: dependencies, extra library storages
;   Advanced options: extra scripting
; Please visit documentation for the other options and examples

platform = espressif32@3.2.1
framework = arduino

build_unflags =

build_flags =

board = esp32dev
platform_packages =
    toolchain-xtensa32 @ ~2.80400.0
    framework-arduinoespressif32 @

lib_deps =

The library is a header only library. So I have added a new library.json file with this content in it.

  "name": "units",
  "version": "3.0.0",
  "description": "This library offert units types",
    "type": "git",
    "url": ""
  "build" : {
    "includeDir" : "include"
  "export" : {
      "exclude" : [
      "name": "CIMEQ"
  "frameworks": "*",
  "platforms": "*"

I was in the impression that export/exclude will do the trick of disabling the copy of unitTests folder to libdeps but it’s not working.

If I use the command:

pio package pack

I see the exporting is working within the resulting tar.gz file.

Is there a way of not including this folder to be compiled in ?


Maybe try and set the srcDir also to this folder, since the library has no actual source, but it might prevent unitTests from being detected as the source dir. It might also be possible using srcFilter.

Put the srcDir to include fix the problem.

Thanx @maxgerhardt