Please provide the content of the CMakeLists.txt file of the external project you are adding. So far, I cannot reproduce the problem with CMake 3.31.1, but I’m on macOS at the moment.
Also, setting PREFIX to the same directory as SOURCE_DIR is highly questionable. It will result in ExternalProject creating various directories in the external project’s sources. You should consider the PREFIX location to be owned by CMake and CMake could create arbitrary files and directories in there. You definitely don’t want to be mixing that with the sources of any external project. If you didn’t specify SOURCE_DIR, ExternalProject would have put the sources in a subdirectory of the prefix path.
Actually, unless you have a very good reason, I’d normally recommend not specifying a PREFIX at all and just let ExternalProject use its default. Same for the BINARY_DIR for that matter. You’ll run into fewer problems if you avoid straying too far from the defaults and putting things in non-default locations.
I ended up removing PREFIX and changing the COMMAND’s (no longer running cd in a command) to eventually get it to work on 3.31.2. I believe we were just using it incorrectly.