Recursively clean CMake build directories
CMake build directories might contain 100s of megabytes of files for large projects. Over time, a developer computer might contain forgotten build directories that waste tens of gigabytes of disk space. With Python, a script using send2trash allows safe removal of CMake build directories by first moving them to the OS Trash / Recycle bin.
| OS | Trash location |
|---|---|
| macOS | ~/.Trash |
| Linux | ~/.local/share/Trash/files |
| Windows | Hidden folder accessed from Powershell like Get-ChildItem -Path 'C:\$Recycle.Bin' -Force |
In distinction from shutil.rmtree, this send2trash approach allows recovery of files if the deletion was accidental. The heuristic used to detect a CMake build directory was inspired by ctest_empty_binary_directory.