Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[conf] to define vs version for msvc #2054

Merged
merged 6 commits into from Mar 30, 2021
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 5 additions & 1 deletion reference/conanfile/tools/microsoft.rst
Expand Up @@ -146,7 +146,7 @@ And it can also be fully instantiated in the conanfile ``generate()`` method:
tc.generate()


The ``MSBuildToolchain`` will generate two files after a ``conan install`` command:
The ``MSBuildToolchain`` will generate three files after a ``conan install`` command:

.. code-block:: bash

Expand All @@ -158,6 +158,10 @@ The ``MSBuildToolchain`` will generate two files after a ``conan install`` comma
- A *conantoolchain_<config>.props* file, that will be conditionally included from the previous
*conantoolchain.props* file based on the configuration and platform, e.g.:
*conantoolchain_release_x86.props*
- A *conanvcvars.bat* file with the necessary ``vcvars`` invocation to define the build environment if necessary
to build from the command line or from automated tools (might not be necessary if opening the IDE). This file
will be automatically called by the ``tools.microsoft.MSBuild`` helper ``build()`` method.


Every invocation to ``conan install`` with different configuration will create a new properties ``.props``
file, that will also be conditionally included. This allows to install different configurations,
Expand Down
23 changes: 23 additions & 0 deletions reference/config_files/settings.yml.rst
Expand Up @@ -152,8 +152,31 @@ The new ``msvc`` compiler is a new, **experimental** one, that is intended to de
- It is only used by the new build integrations in :ref:`conan_tools_cmake` and :ref:`conan_tools_microsoft`, but not the previous ones.
- At the moment it implements a ``compatible_packages`` fallback to Visual Studio compiled packages, that is, previous existing binaries
compiled with ``settings.compiler="Visual Studio"`` can be used for the ``msvc`` compiler if no binaries exist for it yet.
This behavior can be opted-out with ``core.package_id:msvc_visual_incompatible`` [conf] configuration.
memsharded marked this conversation as resolved.
Show resolved Hide resolved
- It is not detected by the profile auto-detect, it needs to explicitly be defined in profiles.

When using the ``msvc`` compiler, the Visual Studio toolset version (the actual ``vcvars`` activation and ``MSBuild`` location) will be
defined by the default provide of that compiler version:

- ``msvc`` compiler version '19.0': Visual Studio 14 2015
- ``msvc`` compiler version '19.1': Visual Studio 15 2017
- ``msvc`` compiler version '19.2': Visual Studio 16 2019

This can be configured in your profiles with the ``tools.microsoft.msbuild:vs_version`` configuration:
czoido marked this conversation as resolved.
Show resolved Hide resolved

.. code-block:: text

[settings]
compiler=msvc
compiler.version=19.0

[conf]
tools.microsoft.msbuild:vs_version = 16


In this case, the ``vcvars`` will activate the Visual Studio 16 installation, but the ``19.0`` compiler version will still be used
because the necessary ``toolset=v140`` will be set.


Architectures
-------------
Expand Down