Instead of copying the folder and renaming the folder, it is better to just copy the folder, because if the folder exists (e.g. cmake has already been run, or it is being run again to recompile after a change), it will not fail with "Directory is not empty" for rename, but instead update the contents in the files accordingly. There will be duplication but it's the size is small and it's the build directory so it doesn't really matter.
Instead of copying the folder and renaming the folder, it is better to just copy the folder, because if the folder exists (e.g. cmake has already been run, or it is being run again to recompile after a change), it will not fail with "Directory is not empty" for rename, but instead update the contents in the files accordingly. There will be duplication but it's the size is small and it's the build directory so it doesn't really matter.