Ninja command concatenation incorrect on Windows
If cmake needs to create a list of commands it creates one ninja command
cmd.exe /C "cmd1 && cmd2 && ..."
with cmdX being the complete command line including arguments. This fails if one of the cmdX contains the "||"-operator for error handling, see attached CMakeLists.txt. We use this to delete the target file if the first command fails in a POST_BUILD rule but here in the example it shows the effect without build too.
The attached project works correctly on Linux with Makefiles and Ninja and on Windows with NMake/JOM printing "first" and "second". But it fails on Windows with Ninja because of different preference of || and && operators in cmd.exe compared to Linux shell.
To fix this the commands can be grouped by brackets:
cmd.exe /C "( cmd1 ) && ( cmd2 ) && ..."
Currently we add these brackets manually as a workaround.
I can create a merge request to do this automatically if desired. Should the brackets by added always or only if || is contained?