MacOSX ExternalProject_Add() git unstash problem ( Cmake 3.17.2, git 2.24.2, ninja 1.10.0 )

I am compiling some libraries on MacOSX Catalina with
ExternalProject_Add() and sometimes it fails with a similar to the below
problem with in-source compilations:

y4minput.c.o already exists, no checkout
y4minput.h already exists, no checkout
error: could not restore untracked files from stash
The stash entry is kept in case you need it again.
CMake Error at
/Users/gga/code/applications/mrv/external/BUILD/Darwin-19.4.0-64/Release/tmp/libvpx-prefix/tmp/libvpx-gitupdate.cmake:133
(message):

Failed to unstash changes in:
‘/Users/gga/code/applications/mrv/external/BUILD/Darwin-19.4.0-64/Release/tmp/libvpx-prefix/src/libvpx/’.

You will have to resolve the conflicts manually

Funny thing is that if I remove the whole prefix directory or run git
stash drop the problem goes away until it shows again in another of the
libraries I am compiling. I need help as I am trying to batch compile
a large number of libraries and this is preventing it.

The project seems to write to its source directory. ExternalProject’s git mechanisms assumes that it is the only thing writing to that source tree, but it tries to keep modifications, but it is a bit ham-fisted with its approach to that. If you can use a separate build directory, I’d suggest that first. If that isn’t possible, is using a tarball instead of git viable? Without cleaning the source tree (and basically killing incremental builds for in-source builds), this is not an easy problem to solve in general. (Submodules run into the same problem with git stash not behaving well if they’re modified.)