VS: Custom commands cannot be canceled
cmake version 3.24.0-rc3
The VS generator creates an entry in the solution file for custom commands that looks something like this:
<Command>setlocal
--- your command goes here ----
if %errorlevel% neq 0 goto :cmEnd
:cmEnd
endlocal & call :cmErrorLevel %errorlevel% & goto :cmDone
:cmErrorLevel
exit /b %1
:cmDone
if %errorlevel% neq 0 goto :VCEnd</Command>
When you build this in VS, and then attempt to cancel it, you get output such as this:
Attempting to cancel the build...
C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(248,5): warning MSB4220: Waiting for the
currently executing task "CustomBuild" to cancel. [C:\Users\cjamc\code\ZeldaClassic\build\run_replay_tests_all_1s.vcxproj]
But the build step will not actually end until the custom command finishes. As far as I can tell, there is no signal sent to the process started by the command that can be listened for to force quit from within.
My understanding is that VS custom commands should be using VS's "task" system, which can implement a way to cancel whatever processes was spawned (either by force killing them or sending a "cancel" signal somehow). See https://stackoverflow.com/questions/43364914/how-to-cancel-build-process-in-visualstudio-for-a-long-running-custom-build-tool