How to run a .bat file from CMake

batch-filecmake

How do I run a .bat file from CMake in a pre-link or a post-build event?

Best Solution

You could use add_custom_command, e.g.

if(WIN32)
  add_custom_command(TARGET <Your target>
                       POST_BUILD
                       COMMAND cmd //C <path to .bat file> <ARGS> )

endif()


For full details about add_custom_command run

cmake --help-command add_custom_command