@echo off
title WebRadar — Install vcpkg Dependencies

set VSPATH=
if exist "%ProgramFiles%\Microsoft Visual Studio\Installer\vswhere.exe" (
    for /f "tokens=* usebackq" %%a in (
        `"%ProgramFiles%\Microsoft Visual Studio\Installer\vswhere.exe" -latest -property installationPath`
    ) do set VSPATH=%%a
)
if "%VSPATH%"=="" (
    if exist "%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" (
        for /f "tokens=* usebackq" %%a in (
            `"%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" -latest -property installationPath`
        ) do set VSPATH=%%a
    )
)
if "%VSPATH%"=="" (
    if exist "C:\Program Files\Microsoft Visual Studio\2022\Community" set VSPATH=C:\Program Files\Microsoft Visual Studio\2022\Community
)
if "%VSPATH%"=="" (
    echo ERROR: Cannot find Visual Studio 2022!
    pause
    exit /b 1
)

call "%VSPATH%\VC\Auxiliary\Build\vcvarsall.bat" x64 > nul 2>&1
vcpkg install --triplet x64-windows-static
echo EXIT_CODE=%ERRORLEVEL%
pause
