ExternalProject_Add fails when patching inside a git submodule
I'm trying to use ExternalProject_Add/FetchContent with a git repository that has submodules where I need to patch files within one of the submodules.
The error is:
Current branch master is up to date.
No stash found.
No stash found.
No stash found.
CMake Error at ... (message):
Failed to unstash changes in:
'.../'.
You will have to resolve the conflicts manually
I think the issue is that CMake thinks it needs to stash/unstash something because the top-level repo is dirty due to the patched files inside a git submodule. However, stashing from the top-level repo wouldn't do anything, since the change is inside the submodule. And this then probably confuses the logic when it's trying to unstash and git exits with non-zero exit code for "No stash found".