Cpp file in src not found

I am using googtest to test a project

The project contains a number of standard H and cpp files in the src directory

When I run the tests the compiler fails with an undefined reference - it looks like the compiler cannot load the cpp file.

When I add a the following to the unit test it compiles successfully

#include "dry_enum.h"
#include "dry_enum.cpp"

The normal build of a arduino target works fine.

Why is this happening?
Why do i need to add the specific include of the cpp file?

thanks

As documented

https://docs.platformio.org/en/latest/projectconf/sections/env/options/test/test_build_src.html

you should refactor to-be-unit-tested logic into its own library in lib/, then the unit tests will automatically find it. Not so if they’re in src/, by default.