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

Add new msvs_toolset #2951

Merged
merged 5 commits into from
Feb 8, 2023
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 31 additions & 2 deletions reference/conanfile/tools/microsoft.rst
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ Parameters:

- **conanfile**: ConanFile instance.
- **build_context** (since `1.52.0 <https://github.com/conan-io/conan/releases/tag/1.52.0>`_): (default=False). If this
argument is ``True``, the method will check the compiler of the ``build`` context, not the ``host`` one.
argument is ``True``, the method will check the compiler of the ``build`` context, not the ``host`` one.

.. code-block:: python

Expand Down Expand Up @@ -632,6 +632,35 @@ Example:
check_min_vs(self, "192")


.. _conan_tools_microsoft_msvs_toolset:

msvs_toolset()
--------------

Available since: `1.59.0 <https://github.com/conan-io/conan/releases/tag/1.59.0>`_

.. code-block:: python

def msvs_toolset(conanfile)

Returns the corresponding Visual Studio or msvs platform toolset based on the settings of the given ``conanfile``. For instance, it may return ``v143``
for ``compiler=Visual Studio`` with ``compiler.version=17``. If ``compiler.toolset`` was set in settings, it has a priority and always returned.
uilianries marked this conversation as resolved.
Show resolved Hide resolved
In case of invalid compiler or invalid version, ``msvs_toolset`` returns an empty string.

Parameters:
- ``conanfile``: Always use ``self``, the current recipe

Example:

.. code-block:: python

from conan.tools.microsoft import msvs_toolset
uilianries marked this conversation as resolved.
Show resolved Hide resolved

def validate(self):
toolset = msvs_toolset(self)
if Version(toolset) < "v110":
uilianries marked this conversation as resolved.
Show resolved Hide resolved
raise ConanInvalidConfiguration(f"{self.ref} requires Microsoft compiler toolset v110 at least.")


NMakeDeps
---------
Expand Down Expand Up @@ -660,7 +689,7 @@ This generator can be used as:
self.run(f"nmake /f makefile")

The generator will create a ``conannmakedeps.bat`` environment script that defines
``CL``, ``LIB`` and ``_LINK_`` environment variables, injecting necessary flags
``CL``, ``LIB`` and ``_LINK_`` environment variables, injecting necessary flags
to locate and link the dependencies declared in ``requires``.
This generator should most likely be used together with ``NMakeToolchain`` one.

Expand Down