Is it possible to use a portable "Microsoft Build Tools 2019" installation with the "Visual Studio 16 2019" generator?
I'm trying to create a 100% portable toolchain that does not require administrator privileges to get it up and running. Now I'm stuck with the "Microsoft Build Tools 2019" because CMake is unable to find them if using the "Visual Studio 16 2019" generator.
Here is what I did:
- Copied the directory
C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools
to another computer asC:\portable\vs-build-tools-16.7.2
. - Copied the directory
C:\Program Files (x86)\Windows Kits\10
to another computer asC:\portable\windows-sdk-10.0.18362.0
. - Configuring CMake to use a portable Windows SDK seems to work as follows:
-
Set the
CMAKE_WINDOWS_KITS_10_DIR
environment variable:set "CMAKE_WINDOWS_KITS_10_DIR=C:\portable\windows-sdk-10.0.18362.0"
-
Set the
CMAKE_SYSTEM_VERSION
cache variable:-D CMAKE_SYSTEM_VERSION:STRING=10.0.18362.0
-
This allowed me to build Google Test with the Ninja Multi-Config
generator from a MSVS Developer Prompt initialized as follows:
"C:\portable\vs-build-tools-16.7.2\windows\Common7\Tools\VsDevCmd.bat" -arch=amd64 -host_arch=amd64
Therefore I assume that modifying the CMAKE_TOOLCHAIN_FILE
used to pick up the above portable "installation" should be possible with a bit of work.
But when trying to use the "Visual Studio 16 2019" generator the following error message is raised by CMake v3.19.4:
could not find any instance of Visual Studio.
I've read #19157 where the following is stated:
Also, FYI the IDE generator doesn't care much about the environment from which it is launched. You don't need a
vcvarsall.bat
to use it.
vswhere.exe
is also not able to find the portable installation C:\portable\vs-build-tools-16.7.2
. I assume both CMake and vswhere.exe
use a similar approach to find the available MSVS installations.
Is there anything (environment variable, HKCU registry modification, ...) I can do to allow CMake to find the portable installation?