Skip to content

Instantly share code, notes, and snippets.

@AndrewPardoe
Last active March 8, 2018 21:51
Show Gist options
  • Save AndrewPardoe/689a3b969670787d5dba538bb0a48a1e to your computer and use it in GitHub Desktop.
Save AndrewPardoe/689a3b969670787d5dba538bb0a48a1e to your computer and use it in GitHub Desktop.
My VCVars.cmd file to set up MSVC environment
:: vcvars.ps1 wrapper for PowerShell:
:: c:\bin\scripts\Invoke-CmdScript.ps1 c:\bin\scripts\vcvars.cmd
@echo off
if "%1" EQU "/?" echo Usage: vcvars [arch] [version] & goto :EOF
if "%1" EQU "-?" echo Usage: vcvars [arch] [version] & goto :EOF
if /I "%1" EQU "/help" echo Usage: vcvars [arch] [version] & goto :EOF
if /I "%1" EQU "-help" echo Usage: vcvars [arch] [version] & goto :EOF
:: Push current directory
pushd "%~dp0"
pushd %ProgramFiles(x86)%\"Microsoft Visual Studio"\Installer
for /f "usebackq tokens=*" %%i in (`vswhere -latest -prerelease -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath`) do (
set VCINSTALLDIR=%%i\VC
)
popd
if exist %VCINSTALLDIR%\Auxiliary\Build\vcvarsall.bat (
if "%1" EQU "" call "%VCINSTALLDIR%\Auxiliary\Build\vcvarsall.bat" x86
if "%1" NEQ "" (
if "%2" EQU "" call "%VCINSTALLDIR%\Auxiliary\Build\vcvarsall.bat" %1
if "%2" NEQ "" call "%VCINSTALLDIR%\Auxiliary\Build\vcvarsall.bat" %1 -vcvars_ver=%2
)
set _CL=/nologo /EHsc /diagnostics:caret /permissive- /std:c++latest
)
popd
:: Add CMake to path. Uses the system version, not the one installed with VS. Assumes install location.
set PATH=%PATH%;%ProgramFiles%\CMake\bin
cl -Bv
echo.
:: Set CL to _CL if you want predefined "normal" (for me) settings
echo _CL set to %_CL%
echo.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment