TL;DR: I wish CMake had an optional arg that meant “run vcvarsall x64|x86|etc before doing anything else”.
- I have a buildbot worker script running in a git-for-windows bash shell (basically, msys2)
- The buildmaster can send it compile/test tasks that require pulling source from somewhere, rebuilding it, and testing it.
- A given buildbot worker may be given tasks that are built for x86 or x64 (so we can’t just start a shell that has the right
vcvarsallcall in place, we may need to change the active MSVC compiler for each subsequent task)
- To date, we’ve been using something like
-G Visual Studio 16 2019 -T host=x64 -A Win32(or
-A x64) when configuring CMake, and everything is fine… except of course that this uses MSBuild, which is very very slow.
- We’d like to switch to using
-G Ninja, because it is crazy-faster, but AFAICT there isn’t an equivalent to the
-Aargument for that Generator; to make this work, we have to explicitly call
- Calling vcvarsall.bat ourselves is doable but ugly, because we’re running in git-for-windows-bash (rather than cmd.exe); we can do something like
vsvarsall.bat x64 && set, slurp the env vars dumped via set, massage the file paths into a form that won’t make bash choke (due to backslashes, etc), set them in the environment… and do this before every call to CMake (for either config or for build). This can be made to work, but man oh man is it ugly and fragile.
(1) Is there a better way to do this already?
(2) If not, can CMake somehow add the smarts (that it must already have) to allow the Ninja generator to get the same tool-selection treatment that the VS generator has?