Don't use cmd.exe when generating with Ninja on Windows

Is there any way to use a different shell when generating a ninja file? Currently when ninja generates a run command it uses cmd.exe /c …

Looking through the cmake code, it seems that’s hard coded and cannot be changed as an option. Is there any other way to get around this limitation?

Is there a supported way to alter the ninja file as a last step of configuration?

No, I don’t believe there is a way to change it. The code that gets written to the ninja file is an implementation detail. What is your use case for changing it?

The most obscure of them all: I’m trying to cross compile llvm targeting arm on a windows host: for this, clang needs a bash environment to run the generated commands. I was just hoping I could avoid running the whole process through msys/mingw.

Why does clang need a bash environment?

Because of this little colon here:

Note that I’m building on Windows but I’m targeting Linux ARM

I’ve just learned about COMSPEC - Wikipedia It would be awesome if cmake supported that!

I feel like that would be far better as a CMake script or an explicit shell script rather than trying to embed shell syntax into CMake’s language. I think that FIXME would also be a lot easier if it were a full shell or CMake script too.

The basic issue is that the command is assuming a bash command environment. CMake does not have any way to guarantee that such an environment is available.