XCode new build system: Clean always fails with subdirectory
This is an issue when using the new build system in XCode 12 and 13. Any non-trivial project fails to clean after building, as the new build system will refuse to delete a folder in the build tree.
Tested in CMake 3.19 and CMake 3.21.1
$ cmake --build . --target clean
Command line invocation:
/Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild -project clean_test.xcodeproj clean -target ALL_BUILD -parallelizeTargets -configuration Debug -hideShellScriptEnvironment
User defaults from command line:
HideShellScriptEnvironment = YES
note: Using new build system
note: Building targets in parallel
warning: Refusing to delete `/tmp/Code/cmake/clean_test/build` because it contains one of the projects in this workspace: `/tmp/Code/cmake/clean_test/build/clean_test.xcodeproj`.
error: Could not delete `/tmp/Code/cmake/clean_test/build/test_app` because it was not created by the build system.
warning: Refusing to delete `/tmp/Code/cmake/clean_test/build` because it contains one of the projects in this workspace: `/tmp/Code/cmake/clean_test/build/clean_test.xcodeproj`.
** CLEAN FAILED **
Project that reproduces the issue: clean_test.zip
Edited by Brad King