VCVars¶
Generates a file called conanvcvars.bat
that activates the Visual Studio developer command prompt according
to the current settings by wrapping the vcvarsall
Microsoft bash script.
The VCVars
generator can be used by name in conanfiles:
class Pkg(ConanFile):
generators = "VCVars"
[generators]
VCVars
And it can also be fully instantiated in the conanfile generate()
method:
from conan import ConanFile
from conan.tools.microsoft import VCVars
class Pkg(ConanFile):
settings = "os", "compiler", "arch", "build_type"
requires = "zlib/1.2.11", "bzip2/1.0.8"
def generate(self):
ms = VCVars(self)
ms.generate()
Customization¶
conf¶
VCVars
is affected by these [conf]
variables:
tools.microsoft.msbuild:installation_path
indicates the path to Visual Studio installation folder. For instance:C:\Program Files (x86)\Microsoft Visual Studio\2019\Community
,C:\Program Files (x86)\Microsoft Visual Studio 14.0
, etc.tools.microsoft:winsdk_version
defines the specific winsdk version in the vcvars command line.tools.env.virtualenv:powershell
generates an additionalconanvcvars.ps1
so it can be run from the Powershell console.
Reference¶
- class VCVars(conanfile)¶
VCVars class generator
- Parameters:
conanfile –
< ConanFile object >
The current recipe object. Always useself
.
- generate(scope='build')¶
Creates a
conanvcvars.bat
file with the good args from settings to set environment variables to configure the command line for native 32-bit or 64-bit compilation.- Parameters:
scope –
str
Launcher to be used to run all the variables. For instance, ifbuild
, then it’ll be used theconanbuild
launcher.