Ninja generator with add_custom_command POST_BUILD
When generating Ninja build files, the following CMake commands cause an error on windows.
add_executable(main src/main.cpp) add_custom_command(TARGET main POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy main.exe main2.exe )
cmd.exe /C "cd . && C:\msys64\mingw64\bin\c++.exe CMakeFiles/main.dir/src/main.cpp.obj -o main.exe -Wl,--out-implib,libmain.dll.a -Wl,--major-image-version,0,--minor-image-version,0 -lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32 && cmd.exe /C "cd /D C:\Eclipse_workspace\cmake\Release && "C:\Program Files\CMake\bin\cmake.exe" -E copy main.exe main2.exe""
'cmd.exe' is not recognized as an internal or external command, operable program or batch file.
The build.ninja file contains this rule:
POST_BUILD = cmd.exe /C "cd /D C:\Eclipse_workspace\cmake\Release && "C:\Program Files\CMake\bin\cmake.exe" -E copy main.exe main2.exe"
when I change it to this, it works:
POST_BUILD = cd /D C:\Eclipse_workspace\cmake\Release && "C:\Program Files\CMake\bin\cmake.exe" -E copy main.exe main2.exe