1:: Copyright 2017 - Refael Ackermann
2:: Copyright 2019 - Thomas Kent
3:: Distributed under MIT style license
4:: See accompanying file LICENSE at https://github.com/node4good/windows-autoconf
5:: Forked from version: 1.15.4
6
7@if not defined DEBUG_HELPER @ECHO OFF
8setlocal
9set "InstallerPath=%ProgramFiles(x86)%\Microsoft Visual Studio\Installer"
10if not exist "%InstallerPath%" set "InstallerPath=%ProgramFiles%\Microsoft Visual Studio\Installer"
11if not exist "%InstallerPath%" goto :no-vswhere
12:: Manipulate %Path% for easier " handeling
13set Path=%Path%;%InstallerPath%
14where vswhere 2> nul > nul
15if errorlevel 1 goto :no-vswhere
16set VSWHERE_REQ=-requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64
17set VSWHERE_PRP=-property installationPath
18
19REM Visual Studio 2017 (15.X, toolset 14.1)
20set VSWHERE_LMT=-version "[15.0,16.0)"
21SET VSWHERE_ARGS=-latest -products * %VSWHERE_REQ% %VSWHERE_PRP% %VSWHERE_LMT%
22for /f "usebackq tokens=*" %%i in (`vswhere %VSWHERE_ARGS%`) do (
23    endlocal
24	echo Found with vswhere %%i
25    @rem comment out setting VCINSTALLDIR for Boost.build
26    @rem set "VCINSTALLDIR=%%i\VC\"
27    set "VS150COMNTOOLS=%%i\Common7\Tools\"
28    exit /B 0
29)
30
31REM Visual Studio 2019 (16.X, toolset 14.2)
32set VSWHERE_LMT=-version "[16.0,17.0)"
33SET VSWHERE_ARGS=-latest -products * %VSWHERE_REQ% %VSWHERE_PRP% %VSWHERE_LMT%
34for /f "usebackq tokens=*" %%i in (`vswhere %VSWHERE_ARGS%`) do (
35    endlocal
36	echo Found with vswhere %%i
37    @rem comment out setting VCINSTALLDIR for Boost.build
38    @rem set "VCINSTALLDIR=%%i\VC\"
39    set "VS160COMNTOOLS=%%i\Common7\Tools\"
40    exit /B 0
41)
42
43REM Visual Studio Unknown Version, Beyond 2019
44set VSWHERE_LMT=-version "[17.0)"
45set VSWHERE_PRERELEASE=-prerelease
46SET VSWHERE_ARGS=-latest -products * %VSWHERE_REQ% %VSWHERE_PRP% %VSWHERE_LMT% %VSWHERE_PRERELEASE%
47for /f "usebackq tokens=*" %%i in (`vswhere %VSWHERE_ARGS%`) do (
48    endlocal
49	echo Found with vswhere %%i
50    @rem comment out setting VCINSTALLDIR for Boost.build
51    @rem set "VCINSTALLDIR=%%i\VC\"
52    set "VSUNKCOMNTOOLS=%%i\Common7\Tools\"
53    exit /B 0
54)
55
56:no-vswhere
57endlocal
58echo could not find "vswhere"
59exit /B 1