MSBuild (Visual Studio)¶
Conan can be integrated with MSBuild, the build system of Visual Studio in two different ways:
- Using the
cmakegenerator to create a conanbuildinfo.cmake file.
- Using the
visual_studiogenerator to create a conanbuildinfo.props file.
cmake generator or
cmake_multi if you are using CMake to machine-generate your Visual Studio projects.
However, beware of some current CMake limitations, such as not dealing well with find-packages, because CMake doesn’t know how to handle finding both debug and release packages.
If you want to use the Visual Studio 2017 + CMake integration, check this how-to
With visual_studio generator¶
Use the visual_studio generator, or visual_studio_multi, if you are maintaining your Visual Studio projects, and want to use Conan to to tell Visual Studio how to find your third-party dependencies.
You can use the visual_studio generator to manage your requirements via your Visual Studio project.
This generator creates a Visual Studio project properties file, with all the include paths, lib paths, libs, flags etc., that can be imported in your project.
conanfile.txt and change (or add) the
[requires] poco/1.9.4 [generators] visual_studio
Install the requirements:
$ conan install .
Go to your Visual Studio project, and open the Property Manager (usually in View -> Other Windows -> Property Manager).
Click the + icon and select the generated
Build your project as usual.
Remember to set your project’s architecture and build type accordingly, explicitly or implicitly, when issuing the conan install command. If these values don’t match, your build will probably fail.
Check visual_studio for the complete reference.
Calling Visual Studio compiler¶
You can call the Visual Studio compiler from your
build() method using the
VisualStudioBuildEnvironment and the
Check the MSBuild section for more info.
Build an existing Visual Studio project¶
You can build an existing Visual Studio from your
build() method using the MSBuild() build helper.
from conans import ConanFile, MSBuild class ExampleConan(ConanFile): ... def build(self): msbuild = MSBuild(self) msbuild.build("MyProject.sln")
You can use the sub-setting
toolset of the Visual Studio compiler to specify a custom toolset.
It will be automatically applied when using the
MSBuild() build helpers.
The toolset can also be specified manually in these build helpers with the
By default, Conan will not generate a new binary package if the specified
matches an already generated package for the corresponding
Check the package_id() reference to learn more.
Check the CMake() reference section for more info.