From 8b656a8d65701b5b65146151d773ed8f47e49eed Mon Sep 17 00:00:00 2001 From: memsharded Date: Tue, 30 Mar 2021 12:55:39 +0200 Subject: [PATCH 1/5] [conf] to define vs version for msvc --- reference/config_files/settings.yml.rst | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/reference/config_files/settings.yml.rst b/reference/config_files/settings.yml.rst index 77e51210a5f..d030032d1de 100644 --- a/reference/config_files/settings.yml.rst +++ b/reference/config_files/settings.yml.rst @@ -152,8 +152,30 @@ 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. - 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: + +``` +[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 ------------- From 96763ed071ff5975e4691a60af7a45f0742d09ea Mon Sep 17 00:00:00 2001 From: memsharded Date: Tue, 30 Mar 2021 13:08:27 +0200 Subject: [PATCH 2/5] notes about ``conanvcvars.bat`` file creation --- reference/conanfile/tools/microsoft.rst | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/reference/conanfile/tools/microsoft.rst b/reference/conanfile/tools/microsoft.rst index 163af330f23..45dc9dc4f4e 100644 --- a/reference/conanfile/tools/microsoft.rst +++ b/reference/conanfile/tools/microsoft.rst @@ -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 @@ -158,6 +158,10 @@ The ``MSBuildToolchain`` will generate two files after a ``conan install`` comma - A *conantoolchain_.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, From 6266bbbc5726ddca658d81d48e53570443e589a5 Mon Sep 17 00:00:00 2001 From: memsharded Date: Tue, 30 Mar 2021 13:35:59 +0200 Subject: [PATCH 3/5] fix ci --- reference/config_files/settings.yml.rst | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/reference/config_files/settings.yml.rst b/reference/config_files/settings.yml.rst index d030032d1de..6329bdc9665 100644 --- a/reference/config_files/settings.yml.rst +++ b/reference/config_files/settings.yml.rst @@ -164,14 +164,15 @@ defined by the default provide of that compiler version: This can be configured in your profiles with the ``tools.microsoft.msbuild:vs_version`` configuration: -``` -[settings] -compiler=msvc -compiler.version=19.0 - -[conf] -tools.microsoft.msbuild:vs_version = 16 -``` +.. 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. From 641fc94c8513b251564886942ee88b6d2bc4adc1 Mon Sep 17 00:00:00 2001 From: James Date: Tue, 30 Mar 2021 15:56:42 +0200 Subject: [PATCH 4/5] Update reference/config_files/settings.yml.rst Co-authored-by: Carlos Zoido --- reference/config_files/settings.yml.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reference/config_files/settings.yml.rst b/reference/config_files/settings.yml.rst index 6329bdc9665..ea75a09f94a 100644 --- a/reference/config_files/settings.yml.rst +++ b/reference/config_files/settings.yml.rst @@ -152,7 +152,7 @@ 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. + This behavior can be opted-out with ``core.package_id:msvc_visual_incompatible`` :ref:`global_conf` configuration. - 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 From b3855b7959a896582b173cfe52fffd7cbb8b0d32 Mon Sep 17 00:00:00 2001 From: czoido Date: Tue, 30 Mar 2021 18:44:14 +0200 Subject: [PATCH 5/5] add to conf --- reference/config_files/global_conf.rst | 3 +++ 1 file changed, 3 insertions(+) diff --git a/reference/config_files/global_conf.rst b/reference/config_files/global_conf.rst index d2b9a75ed5f..be1f3a423fb 100644 --- a/reference/config_files/global_conf.rst +++ b/reference/config_files/global_conf.rst @@ -32,6 +32,7 @@ have priority over globally defined ones in *global.conf*, and can be defined as [conf] tools.microsoft.msbuild:verbosity=Diagnostic tools.microsoft.msbuild:max_cpu_count=20 + tools.microsoft.msbuild:vs_version = 16 tools.build:processes=10 tools.ninja:jobs=30 tools.gnu.make:jobs=40 @@ -46,6 +47,8 @@ Existing configurations: - ``tools.microsoft.msbuild:max_cpu_count`` argument for the ``/m`` (``/maxCpuCount``) when running ``MSBuild`` standalone or via CMake (overrides the general ``tools.build:processes``). +- ``tools.microsoft.msbuild:vs_version`` defines the compiler version when using using the new ``msvc`` compiler. + - ``tools.build:processes``: number of processes to use for every build-helper. - ``tools.ninja:jobs`` argument for the ``--jobs`` parameter when running Ninja generator via CMake