Need help excluding a cpp in a library from compiling

Hi,

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
; https://docs.platformio.org/page/projectconf.html

[env:esp32dev]
platform = espressif32@3.2.1
framework = arduino

build_unflags =
    -std=gnu++11
    -fexceptions

build_flags =
    -DCORE_DEBUG_LEVEL=5
    -DDISABLE_PREDEFINED_UNITS
    -DENABLE_PREDEFINED_VOLTAGE_UNITS
    -DDISABLE_IOSTREAM=ON
    -std=gnu++17

board = esp32dev
platform_packages =
    toolchain-xtensa32 @ ~2.80400.0
    framework-arduinoespressif32 @ https://github.com/espressif/arduino-esp32.git#2.0.0-alpha1

lib_deps = https://github.com/cimeq/units.git

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",
  "repository":
  {
    "type": "git",
    "url": "https://github.com/cimeq/units.git"
    
  },
  "build" : {
    "includeDir" : "include"
  },
  "export" : {
      "exclude" : [
        "unitTests",
        ".github",
        ".git",
        "3rdParty"
      ]
  },
  "authors":
  [
    {
      "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 ?

Regards

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