From a620e5b7ba6b0d2128edd2056b7391b5fabcd77d Mon Sep 17 00:00:00 2001 From: SSE4 Date: Mon, 30 Aug 2021 23:20:01 +0700 Subject: [PATCH] Feature: Visual Studio 2022 (#9370) * - define settings for Visual Studio 2022 Signed-off-by: SSE4 * - update cppstd for Visual Studio 2022 Signed-off-by: SSE4 * - update MSVC detection Signed-off-by: SSE4 * - update MSVC toolset Signed-off-by: SSE4 * - update CMake generator for Visual Studio 2022 Signed-off-by: SSE4 * - update compiler check for Visual Studio 2019 Signed-off-by: SSE4 * - update MSVC_YEAR, just in case (so far, only used for Intel compiler) Signed-off-by: SSE4 * - update mapping in new toolchain Signed-off-by: SSE4 * - fix build_sln_command test Signed-off-by: SSE4 * - add VS2022 cppstd for new toolchain Signed-off-by: SSE4 * Update conans/client/migrations_settings.py * Update conans/client/conf/__init__.py * Update conans/client/conf/__init__.py * - add 19.3 to the IDE version mapping Signed-off-by: SSE4 * - add new tests Signed-off-by: SSE4 * - new test Signed-off-by: SSE4 * - mock vcvars_path, as VS17 is not installed, and for Linux/Macos Signed-off-by: SSE4 * - mapping for msvc_compatible Signed-off-by: SSE4 * - copy tests for VS2022 Signed-off-by: SSE4 * - mark VS 2022 as disabled, so pytest mark doesn't fail, but just skips Signed-off-by: SSE4 * - oops, type Signed-off-by: SSE4 --- conan/tools/_compilers.py | 12 +- conan/tools/cmake/toolchain.py | 3 +- conan/tools/microsoft/toolchain.py | 9 +- conan/tools/microsoft/visual.py | 6 +- conans/client/build/cmake_flags.py | 3 +- conans/client/build/cppstd_flags.py | 12 +- conans/client/conf/__init__.py | 9 +- conans/client/conf/compiler_id.py | 13 +- conans/client/generators/cmake_common.py | 2 + conans/client/migrations_settings.py | 121 +++++++++++++++++- conans/client/tools/win.py | 9 +- conans/model/info.py | 3 +- conans/test/conftest.py | 4 +- .../toolchains/microsoft/test_msbuild.py | 76 +++++++---- .../toolchains/microsoft/test_msbuilddeps.py | 72 ++++++++--- conans/test/functional/utils.py | 2 +- .../client/build/compiler_id_test.py | 8 +- .../client/build/cpp_std_flags_test.py | 3 +- .../unittests/client/build/msbuild_test.py | 6 +- .../model/info/vs_toolset_compatible_test.py | 3 +- .../tools/cmake/test_cmaketoolchain.py | 27 ++++ .../unittests/tools/microsoft/test_msbuild.py | 48 ++++++- .../unittests/util/build_sln_command_test.py | 1 + .../test/unittests/util/msvs_toolset_test.py | 3 +- 24 files changed, 383 insertions(+), 72 deletions(-) diff --git a/conan/tools/_compilers.py b/conan/tools/_compilers.py index 23c952a92ae..e316f49ff42 100644 --- a/conan/tools/_compilers.py +++ b/conan/tools/_compilers.py @@ -152,6 +152,7 @@ def _cppstd_visualstudio(visual_version, cppstd): v14 = None v17 = None v20 = None + v23 = None if Version(visual_version) >= "14": v14 = "c++14" @@ -159,8 +160,11 @@ def _cppstd_visualstudio(visual_version, cppstd): if Version(visual_version) >= "15": v17 = "c++17" v20 = "c++latest" + if Version(visual_version) >= "17": + v20 = "c++20" + v23 = "c++latest" - flag = {"14": v14, "17": v17, "20": v20}.get(str(cppstd), None) + flag = {"14": v14, "17": v17, "20": v20, "23": v23}.get(str(cppstd), None) return "/std:%s" % flag if flag else None @@ -169,6 +173,7 @@ def _cppstd_msvc(visual_version, cppstd): v14 = None v17 = None v20 = None + v23 = None if Version(visual_version) >= "19.0": v14 = "c++14" @@ -176,8 +181,11 @@ def _cppstd_msvc(visual_version, cppstd): if Version(visual_version) >= "19.1": v17 = "c++17" v20 = "c++latest" + if Version(visual_version) >= "19.3": + v20 = "c++20" + v23 = "c++latest" - flag = {"14": v14, "17": v17, "20": v20}.get(str(cppstd), None) + flag = {"14": v14, "17": v17, "20": v20, "23": v23}.get(str(cppstd), None) return "/std:%s" % flag if flag else None diff --git a/conan/tools/cmake/toolchain.py b/conan/tools/cmake/toolchain.py index bcda4883fd0..ebcfc40239a 100644 --- a/conan/tools/cmake/toolchain.py +++ b/conan/tools/cmake/toolchain.py @@ -778,7 +778,8 @@ def _get_generator(self, recipe_generator): '12': '12 2013', '14': '14 2015', '15': '15 2017', - '16': '16 2019'} + '16': '16 2019', + '17': '17 2022'} if compiler == "msvc": if compiler_version is None: diff --git a/conan/tools/microsoft/toolchain.py b/conan/tools/microsoft/toolchain.py index 68a1d1c9caf..01303318f05 100644 --- a/conan/tools/microsoft/toolchain.py +++ b/conan/tools/microsoft/toolchain.py @@ -20,7 +20,8 @@ def vs_ide_version(conanfile): version = compiler_version[:4] # Remove the latest version number 19.1X if existing _visuals = {'19.0': '14', # TODO: This is common to CMake, refactor '19.1': '15', - '19.2': '16'} + '19.2': '16', + '19.3': '17'} visual_version = _visuals[version] else: visual_version = compiler_version @@ -66,7 +67,8 @@ def _msvs_toolset(settings): version = compiler_version[:4] # Remove the latest version number 19.1X if existing toolsets = {'19.0': 'v140', # TODO: This is common to CMake, refactor '19.1': 'v141', - '19.2': 'v142'} + '19.2': 'v142', + "19.3": 'v143'} return toolsets[version] if compiler == "intel": compiler_version = compiler_version if "." in compiler_version else \ @@ -75,7 +77,8 @@ def _msvs_toolset(settings): if compiler == "Visual Studio": toolset = settings.get_safe("compiler.toolset") if not toolset: - toolsets = {"16": "v142", + toolsets = {"17": "v143", + "16": "v142", "15": "v141", "14": "v140", "12": "v120", diff --git a/conan/tools/microsoft/visual.py b/conan/tools/microsoft/visual.py index 4db11a37352..06da985a14c 100644 --- a/conan/tools/microsoft/visual.py +++ b/conan/tools/microsoft/visual.py @@ -39,7 +39,8 @@ def _write_conanvcvars(conanfile, auto_activate=True): if toolset is not None: vcvars_ver = {"v140": "14.0", "v141": "14.1", - "v142": "14.2"}.get(toolset) + "v142": "14.2", + "v143": "14.3"}.get(toolset) else: # Code similar to CMakeToolchain toolset one compiler_version = str(conanfile.settings.compiler.version) @@ -74,7 +75,8 @@ def vs_ide_version(conanfile): version = compiler_version[:4] # Remove the latest version number 19.1X if existing _visuals = {'19.0': '14', # TODO: This is common to CMake, refactor '19.1': '15', - '19.2': '16'} + '19.2': '16', + '19.3': '17'} visual_version = _visuals[version] else: visual_version = compiler_version diff --git a/conans/client/build/cmake_flags.py b/conans/client/build/cmake_flags.py index a385806d0b9..fbc937108f2 100644 --- a/conans/client/build/cmake_flags.py +++ b/conans/client/build/cmake_flags.py @@ -63,7 +63,8 @@ def get_generator(conanfile): '12': '12 2013', '14': '14 2015', '15': '15 2017', - '16': '16 2019'}.get(major_version, "UnknownVersion %s" % version) + '16': '16 2019', + '17': '17 2022'}.get(major_version, "UnknownVersion %s" % version) base = "Visual Studio %s" % _visuals return base diff --git a/conans/client/build/cppstd_flags.py b/conans/client/build/cppstd_flags.py index 3578cbcbacb..36e46ca5612 100644 --- a/conans/client/build/cppstd_flags.py +++ b/conans/client/build/cppstd_flags.py @@ -103,6 +103,7 @@ def _cppstd_visualstudio(visual_version, cppstd): v14 = None v17 = None v20 = None + v23 = None if Version(visual_version) >= "14": v14 = "c++14" @@ -110,8 +111,11 @@ def _cppstd_visualstudio(visual_version, cppstd): if Version(visual_version) >= "15": v17 = "c++17" v20 = "c++latest" + if Version(visual_version) >= "17": + v20 = "c++20" + v23 = "c++latest" - flag = {"14": v14, "17": v17, "20": v20}.get(str(cppstd), None) + flag = {"14": v14, "17": v17, "20": v20, "23": v23}.get(str(cppstd), None) return "/std:%s" % flag if flag else None @@ -120,6 +124,7 @@ def _cppstd_msvc(visual_version, cppstd): v14 = None v17 = None v20 = None + v23 = None if Version(visual_version) >= "19.0": v14 = "c++14" @@ -127,8 +132,11 @@ def _cppstd_msvc(visual_version, cppstd): if Version(visual_version) >= "19.1": v17 = "c++17" v20 = "c++latest" + if Version(visual_version) >= "19.3": + v20 = "c++20" + v23 = "c++latest" - flag = {"14": v14, "17": v17, "20": v20}.get(str(cppstd), None) + flag = {"14": v14, "17": v17, "20": v20, "23": v23}.get(str(cppstd), None) return "/std:%s" % flag if flag else None diff --git a/conans/client/conf/__init__.py b/conans/client/conf/__init__.py index 739287e8ce8..26a17c5eb41 100644 --- a/conans/client/conf/__init__.py +++ b/conans/client/conf/__init__.py @@ -78,20 +78,21 @@ cppstd: [None, 98, gnu98, 11, gnu11, 14, gnu14, 17, gnu17, 20, gnu20, 23, gnu23] Visual Studio: &visual_studio runtime: [MD, MT, MTd, MDd] - version: ["8", "9", "10", "11", "12", "14", "15", "16"] + version: ["8", "9", "10", "11", "12", "14", "15", "16", "17"] toolset: [None, v90, v100, v110, v110_xp, v120, v120_xp, v140, v140_xp, v140_clang_c2, LLVM-vs2012, LLVM-vs2012_xp, LLVM-vs2013, LLVM-vs2013_xp, LLVM-vs2014, LLVM-vs2014_xp, LLVM-vs2017, LLVM-vs2017_xp, v141, v141_xp, v141_clang_c2, v142, - llvm, ClangCL] + llvm, ClangCL, v143] cppstd: [None, 14, 17, 20] msvc: version: ["19.0", "19.1", "19.10", "19.11", "19.12", "19.13", "19.14", "19.15", "19.16", - "19.2", "19.20", "19.21", "19.22", "19.23", "19.24", "19.25", "19.26", "19.27", "19.28"] + "19.2", "19.20", "19.21", "19.22", "19.23", "19.24", "19.25", "19.26", "19.27", "19.28", "19.29", + "19.3", "19.30"] runtime: [static, dynamic] runtime_type: [Debug, Release] - cppstd: [14, 17, 20] + cppstd: [14, 17, 20, 23] clang: version: ["3.3", "3.4", "3.5", "3.6", "3.7", "3.8", "3.9", "4.0", "5.0", "6.0", "7.0", "7.1", diff --git a/conans/client/conf/compiler_id.py b/conans/client/conf/compiler_id.py index 973cf0be0c8..9fa32e50036 100644 --- a/conans/client/conf/compiler_id.py +++ b/conans/client/conf/compiler_id.py @@ -98,7 +98,10 @@ def __ne__(self, other): 1924: (16, 4), 1925: (16, 5), 1926: (16, 6), - 1927: (16, 7)} + 1927: (16, 7), + 1928: (16, 8), + 1929: (16, 10), + 1930: (17, 0)} def _parse_compiler_version(defines): @@ -138,6 +141,14 @@ def _parse_compiler_version(defines): # currently, conan uses major only, but here we store minor for the future as well # https://docs.microsoft.com/en-us/cpp/preprocessor/predefined-macros?view=vs-2019 major, minor = MSVC_TO_VS_VERSION.get(version) + # special cases 19.8 and 19.9, 19.10 and 19.11 + full_version = 0 + if '_MSC_FULL_VER' in defines: + full_version = int(defines['_MSC_FULL_VER']) + if (major, minor) == (16, 8) and full_version >= 192829500: + major, minor = 16, 9 + if (major, minor) == (16, 10) and full_version >= 192930100: + major, minor = 16, 11 patch = 0 # GCC must be the last try, as other compilers may define __GNUC__ for compatibility elif '__GNUC__' in defines: diff --git a/conans/client/generators/cmake_common.py b/conans/client/generators/cmake_common.py index 9ea3056e0fd..f0074763562 100644 --- a/conans/client/generators/cmake_common.py +++ b/conans/client/generators/cmake_common.py @@ -471,6 +471,8 @@ class CMakeCommonMacros: # https://cmake.org/cmake/help/v2.8.2/cmake.html#variable:MSVC_VERSION # https://cmake.org/cmake/help/v3.14/variable/MSVC_VERSION.html if( + # 1930 = VS 17.0 (v143 toolset) + (CONAN_COMPILER_VERSION STREQUAL "17" AND NOT MSVC_VERSION EQUAL 1930) OR # 1920-1929 = VS 16.0 (v142 toolset) (CONAN_COMPILER_VERSION STREQUAL "16" AND NOT((MSVC_VERSION GREATER 1919) AND (MSVC_VERSION LESS 1930))) OR # 1910-1919 = VS 15.0 (v141 toolset) diff --git a/conans/client/migrations_settings.py b/conans/client/migrations_settings.py index 79de5fd5ac6..069cfd1bfa6 100644 --- a/conans/client/migrations_settings.py +++ b/conans/client/migrations_settings.py @@ -2310,4 +2310,123 @@ settings_1_39_0 = settings_1_38_0 -settings_1_40_0 = settings_1_39_0 +settings_1_40_0 = settings_1_37_0 = """ +# Only for cross building, 'os_build/arch_build' is the system that runs Conan +os_build: [Windows, WindowsStore, Linux, Macos, FreeBSD, SunOS, AIX] +arch_build: [x86, x86_64, ppc32be, ppc32, ppc64le, ppc64, armv5el, armv5hf, armv6, armv7, armv7hf, armv7s, armv7k, armv8, armv8_32, armv8.3, sparc, sparcv9, mips, mips64, avr, s390, s390x, sh4le, e2k-v2, e2k-v3, e2k-v4, e2k-v5, e2k-v6, e2k-v7] + +# Only for building cross compilation tools, 'os_target/arch_target' is the system for +# which the tools generate code +os_target: [Windows, Linux, Macos, Android, iOS, watchOS, tvOS, FreeBSD, SunOS, AIX, Arduino, Neutrino] +arch_target: [x86, x86_64, ppc32be, ppc32, ppc64le, ppc64, armv5el, armv5hf, armv6, armv7, armv7hf, armv7s, armv7k, armv8, armv8_32, armv8.3, sparc, sparcv9, mips, mips64, avr, s390, s390x, asm.js, wasm, sh4le, e2k-v2, e2k-v3, e2k-v4, e2k-v5, e2k-v6, e2k-v7] + +# Rest of the settings are "host" settings: +# - For native building/cross building: Where the library/program will run. +# - For building cross compilation tools: Where the cross compiler will run. +os: + Windows: + subsystem: [None, cygwin, msys, msys2, wsl] + WindowsStore: + version: ["8.1", "10.0"] + WindowsCE: + platform: ANY + version: ["5.0", "6.0", "7.0", "8.0"] + Linux: + Macos: + version: [None, "10.6", "10.7", "10.8", "10.9", "10.10", "10.11", "10.12", "10.13", "10.14", "10.15", "11.0", "13.0"] + sdk: [None, "macosx"] + subsystem: [None, catalyst] + Android: + api_level: ANY + iOS: + version: ["7.0", "7.1", "8.0", "8.1", "8.2", "8.3", "9.0", "9.1", "9.2", "9.3", "10.0", "10.1", "10.2", "10.3", "11.0", "11.1", "11.2", "11.3", "11.4", "12.0", "12.1", "12.2", "12.3", "12.4", "13.0", "13.1", "13.2", "13.3", "13.4", "13.5", "13.6"] + sdk: [None, "iphoneos", "iphonesimulator"] + watchOS: + version: ["4.0", "4.1", "4.2", "4.3", "5.0", "5.1", "5.2", "5.3", "6.0", "6.1"] + sdk: [None, "watchos", "watchsimulator"] + tvOS: + version: ["11.0", "11.1", "11.2", "11.3", "11.4", "12.0", "12.1", "12.2", "12.3", "12.4", "13.0"] + sdk: [None, "appletvos", "appletvsimulator"] + FreeBSD: + SunOS: + AIX: + Arduino: + board: ANY + Emscripten: + Neutrino: + version: ["6.4", "6.5", "6.6", "7.0", "7.1"] +arch: [x86, x86_64, ppc32be, ppc32, ppc64le, ppc64, armv4, armv4i, armv5el, armv5hf, armv6, armv7, armv7hf, armv7s, armv7k, armv8, armv8_32, armv8.3, sparc, sparcv9, mips, mips64, avr, s390, s390x, asm.js, wasm, sh4le, e2k-v2, e2k-v3, e2k-v4, e2k-v5, e2k-v6, e2k-v7] +compiler: + sun-cc: + version: ["5.10", "5.11", "5.12", "5.13", "5.14", "5.15"] + threads: [None, posix] + libcxx: [libCstd, libstdcxx, libstlport, libstdc++] + gcc: &gcc + version: ["4.1", "4.4", "4.5", "4.6", "4.7", "4.8", "4.9", + "5", "5.1", "5.2", "5.3", "5.4", "5.5", + "6", "6.1", "6.2", "6.3", "6.4", "6.5", + "7", "7.1", "7.2", "7.3", "7.4", "7.5", + "8", "8.1", "8.2", "8.3", "8.4", + "9", "9.1", "9.2", "9.3", + "10", "10.1", "10.2", "10.3", + "11", "11.1"] + libcxx: [libstdc++, libstdc++11] + threads: [None, posix, win32] # Windows MinGW + exception: [None, dwarf2, sjlj, seh] # Windows MinGW + cppstd: [None, 98, gnu98, 11, gnu11, 14, gnu14, 17, gnu17, 20, gnu20, 23, gnu23] + Visual Studio: &visual_studio + runtime: [MD, MT, MTd, MDd] + version: ["8", "9", "10", "11", "12", "14", "15", "16", "17"] + toolset: [None, v90, v100, v110, v110_xp, v120, v120_xp, + v140, v140_xp, v140_clang_c2, LLVM-vs2012, LLVM-vs2012_xp, + LLVM-vs2013, LLVM-vs2013_xp, LLVM-vs2014, LLVM-vs2014_xp, + LLVM-vs2017, LLVM-vs2017_xp, v141, v141_xp, v141_clang_c2, v142, + llvm, ClangCL, v143] + cppstd: [None, 14, 17, 20] + msvc: + version: ["19.0", + "19.1", "19.10", "19.11", "19.12", "19.13", "19.14", "19.15", "19.16", + "19.2", "19.20", "19.21", "19.22", "19.23", "19.24", "19.25", "19.26", "19.27", "19.28", "19.29", + "19.3", "19.30"] + runtime: [static, dynamic] + runtime_type: [Debug, Release] + cppstd: [14, 17, 20, 23] + clang: + version: ["3.3", "3.4", "3.5", "3.6", "3.7", "3.8", "3.9", "4.0", + "5.0", "6.0", "7.0", "7.1", + "8", "9", "10", "11", "12"] + libcxx: [None, libstdc++, libstdc++11, libc++, c++_shared, c++_static] + cppstd: [None, 98, gnu98, 11, gnu11, 14, gnu14, 17, gnu17, 20, gnu20, 23, gnu23] + runtime: [None, MD, MT, MTd, MDd] + apple-clang: &apple_clang + version: ["5.0", "5.1", "6.0", "6.1", "7.0", "7.3", "8.0", "8.1", "9.0", "9.1", "10.0", "11.0", "12.0"] + libcxx: [libstdc++, libc++] + cppstd: [None, 98, gnu98, 11, gnu11, 14, gnu14, 17, gnu17, 20, gnu20] + intel: + version: ["11", "12", "13", "14", "15", "16", "17", "18", "19", "19.1"] + base: + gcc: + <<: *gcc + threads: [None] + exception: [None] + Visual Studio: + <<: *visual_studio + apple-clang: + <<: *apple_clang + qcc: + version: ["4.4", "5.4", "8.3"] + libcxx: [cxx, gpp, cpp, cpp-ne, accp, acpp-ne, ecpp, ecpp-ne] + cppstd: [None, 98, gnu98, 11, gnu11, 14, gnu14, 17, gnu17] + mcst-lcc: + version: ["1.19", "1.20", "1.21", "1.22", "1.23", "1.24", "1.25"] + base: + gcc: + <<: *gcc + threads: [None] + exceptions: [None] + +build_type: [None, Debug, Release, RelWithDebInfo, MinSizeRel] + + +cppstd: [None, 98, gnu98, 11, gnu11, 14, gnu14, 17, gnu17, 20, gnu20, 23, gnu23] # Deprecated, use compiler.cppstd +""" diff --git a/conans/client/tools/win.py b/conans/client/tools/win.py index d04f4f0dd06..618cd8a842b 100644 --- a/conans/client/tools/win.py +++ b/conans/client/tools/win.py @@ -98,7 +98,8 @@ def latest_vs_version_installed(output): return latest_visual_studio_version_installed(output=output) -MSVS_YEAR = {"16": "2019", +MSVS_YEAR = {"17": "2022", + "16": "2019", "15": "2017", "14": "2015", "12": "2013", @@ -108,7 +109,8 @@ def latest_vs_version_installed(output): "8": "2005"} -MSVS_DEFAULT_TOOLSETS = {"16": "v142", +MSVS_DEFAULT_TOOLSETS = {"17": "v143", + "16": "v142", "15": "v141", "14": "v140", "12": "v120", @@ -118,7 +120,8 @@ def latest_vs_version_installed(output): "8": "v80"} # inverse version of the above MSVS_DEFAULT_TOOLSETS (keys and values are swapped) -MSVS_DEFAULT_TOOLSETS_INVERSE = {"v142": "16", +MSVS_DEFAULT_TOOLSETS_INVERSE = {"v143": "17", + "v142": "16", "v141": "15", "v140": "14", "v120": "12", diff --git a/conans/model/info.py b/conans/model/info.py index 8eabacdc727..9fa054a81d9 100644 --- a/conans/model/info.py +++ b/conans/model/info.py @@ -590,7 +590,8 @@ def msvc_compatible(self): version = str(version)[:4] _visuals = {'19.0': '14', '19.1': '15', - '19.2': '16'} + '19.2': '16', + '19.3': '17'} compatible.settings.compiler.version = _visuals[version] runtime = "MT" if runtime == "static" else "MD" if runtime_type == "Debug": diff --git a/conans/test/conftest.py b/conans/test/conftest.py index 161a1973654..6e0023b7b99 100644 --- a/conans/test/conftest.py +++ b/conans/test/conftest.py @@ -37,8 +37,8 @@ "clang": {"disabled": True}, 'visual_studio': {"default": "15", "15": {}, - "16": {"disabled": True}}, - + "16": {"disabled": True}, + "17": {"disabled": True}}, 'pkg_config': {"exe": "pkg-config", "default": "system", # pacman -S pkg-config inside msys2-mingw64 diff --git a/conans/test/functional/toolchains/microsoft/test_msbuild.py b/conans/test/functional/toolchains/microsoft/test_msbuild.py index 26a40531f3e..6ff5b170e63 100644 --- a/conans/test/functional/toolchains/microsoft/test_msbuild.py +++ b/conans/test/functional/toolchains/microsoft/test_msbuild.py @@ -5,7 +5,7 @@ import unittest import pytest -from parameterized import parameterized +from parameterized import parameterized, parameterized_class from conans.client.tools import chdir @@ -13,6 +13,7 @@ from conan.tools.microsoft.visual import vcvars_command from conans.client.tools import vs_installation_path from conans.test.assets.sources import gen_function_cpp +from conans.test.conftest import tools_locations from conans.test.functional.utils import check_vs_runtime, check_exe_run from conans.test.utils.tools import TestClient @@ -305,10 +306,17 @@ """ +@pytest.mark.tool_visual_studio(version='15') +@pytest.mark.skipif(platform.system() != "Windows", reason="Only for windows") +def test_msvc_runtime_flag_vs2017(): + check_msvc_runtime_flag("15", "19.1") -@pytest.mark.tool_visual_studio +@pytest.mark.tool_visual_studio(version='17') @pytest.mark.skipif(platform.system() != "Windows", reason="Only for windows") -def test_msvc_runtime_flag(): +def test_msvc_runtime_flag_vs2022(): + check_msvc_runtime_flag("17", "19.3") + +def check_msvc_runtime_flag(vs_version, msvc_version): client = TestClient() conanfile = textwrap.dedent(""" from conans import ConanFile @@ -320,16 +328,25 @@ def generate(self): self.output.info("MSVC FLAG={}!!".format(msvc_runtime_flag(self))) """) client.save({"conanfile.py": conanfile}) - client.run('install . -s compiler="Visual Studio" -s compiler.version=15 -s compiler.runtime=MD') + client.run('install . -s compiler="Visual Studio" -s compiler.version={vs_version} ' + '-s compiler.runtime=MD'.format(vs_version=vs_version)) assert "MSVC FLAG=MD!!" in client.out - client.run('install . -s compiler=msvc -s compiler.version=19.1 -s compiler.runtime=static ' - '-s compiler.runtime_type=Debug -s compiler.cppstd=14') + client.run('install . -s compiler=msvc -s compiler.version={msvc_version} ' + '-s compiler.runtime=static ' + '-s compiler.runtime_type=Debug ' + '-s compiler.cppstd=14'.format(msvc_version=msvc_version)) assert "MSVC FLAG=MTd!!" in client.out - client.run('install . -s compiler=msvc -s compiler.version=19.1 -s compiler.runtime=dynamic ' - '-s compiler.cppstd=14') + client.run('install . -s compiler=msvc -s compiler.version={msvc_version} ' + '-s compiler.runtime=dynamic ' + '-s compiler.cppstd=14'.format(msvc_version=msvc_version)) assert "MSVC FLAG=MD!!" in client.out +vs_versions = [{"vs_version": "15", "msvc_version": "19.1", "ide_year": "2017", "toolset": "v141"}] +if "17" in tools_locations['visual_studio'] and not tools_locations['visual_studio']['17'].get('disabled', False): + vs_versions.append({"vs_version": "17", "msvc_version": "19.3", "ide_year": "2022", "toolset": "v143"}) + +@parameterized_class(vs_versions) @pytest.mark.skipif(platform.system() != "Windows", reason="Only for windows") @pytest.mark.tool_visual_studio class WinTest(unittest.TestCase): @@ -408,7 +425,22 @@ def _run_app(client, arch, build_type, shared=None): ("msvc", "19.0", "static", "14")] ) @pytest.mark.tool_cmake - def test_toolchain_win(self, compiler, version, runtime, cppstd): + def test_toolchain_win_vs2017(self, compiler, version, runtime, cppstd): + if self.vs_version != "15": + pytest.skip("test for Visual Studio 2017") + else: + self.check_toolchain_win(compiler, version, runtime, cppstd) + + @parameterized.expand([("Visual Studio", "17", "MT", "17"), + ("msvc", "19.3", "static", "17")] + ) + def test_toolchain_win_vs2022(self, compiler, version, runtime, cppstd): + if self.vs_version != "17": + pytest.skip("test for Visual Studio 2022") + else: + self.check_toolchain_win(compiler, version, runtime, cppstd) + + def check_toolchain_win(self, compiler, version, runtime, cppstd): client = TestClient(path_with_spaces=False) settings = [("compiler", compiler), ("compiler.version", version), @@ -422,8 +454,8 @@ def test_toolchain_win(self, compiler, version, runtime, cppstd): os=Windows [conf] - tools.microsoft.msbuild:vs_version=15 - """) + tools.microsoft.msbuild:vs_version={vs_version} + """.format(vs_version=self.vs_version)) client.save({"myprofile": profile}) # Build the profile according to the settings provided settings = " ".join('-s %s="%s"' % (k, v) for k, v in settings if v) @@ -444,12 +476,12 @@ def test_toolchain_win(self, compiler, version, runtime, cppstd): self.assertIn("conanfile.py: MSBuildToolchain created conantoolchain_release_win32.props", client.out) client.run("build . -if=conan") - self.assertIn("Visual Studio 2017", client.out) + self.assertIn("Visual Studio {ide_year}".format(ide_year=self.ide_year), client.out) self.assertIn("[vcvarsall.bat] Environment initialized for: 'x86'", client.out) self._run_app(client, "x86", "Release") self.assertIn("Hello World Release", client.out) - compiler_version = version if compiler == "msvc" else "19.1" + compiler_version = version if compiler == "msvc" else self.msvc_version check_exe_run(client.out, "main", "msvc", compiler_version, "Release", "x86", cppstd, {"DEFINITIONS_BOTH": 'True', "DEFINITIONS_BOTH2": "True", @@ -458,14 +490,14 @@ def test_toolchain_win(self, compiler, version, runtime, cppstd): "DEFINITIONS_CONFIG2": 'Release', "DEFINITIONS_CONFIG_INT": "456"}) static_runtime = True if runtime == "static" or "MT" in runtime else False - check_vs_runtime("Release/MyApp.exe", client, "15", build_type="Release", + check_vs_runtime("Release/MyApp.exe", client, self.vs_version, build_type="Release", static_runtime=static_runtime) @pytest.mark.tool_cmake def test_toolchain_win_debug(self): client = TestClient(path_with_spaces=False) settings = [("compiler", "Visual Studio"), - ("compiler.version", "15"), + ("compiler.version", self.vs_version), ("compiler.toolset", "v140"), ("compiler.runtime", "MDd"), ("build_type", "Debug"), @@ -489,7 +521,7 @@ def test_toolchain_win_debug(self): self.assertIn("conanfile.py: MSBuildToolchain created conantoolchain_debug_x64.props", client.out) client.run("build . -if=conan") - self.assertIn("Visual Studio 2017", client.out) + self.assertIn("Visual Studio {ide_year}".format(ide_year=self.ide_year), client.out) self.assertIn("[vcvarsall.bat] Environment initialized for: 'x64'", client.out) self._run_app(client, "x64", "Debug") self.assertIn("Hello World Debug", client.out) @@ -500,14 +532,14 @@ def test_toolchain_win_debug(self): "DEFINITIONS_CONFIG": 'Debug', "DEFINITIONS_CONFIG2": 'Debug', "DEFINITIONS_CONFIG_INT": "234"}) - check_vs_runtime("x64/Debug/MyApp.exe", client, "15", build_type="Debug") + check_vs_runtime("x64/Debug/MyApp.exe", client, self.vs_version, build_type="Debug") @pytest.mark.tool_cmake def test_toolchain_win_multi(self): client = TestClient(path_with_spaces=False) settings = [("compiler", "Visual Studio"), - ("compiler.version", "15"), + ("compiler.version", self.vs_version), ("compiler.cppstd", "17")] settings = " ".join('-s %s="%s"' % (k, v) for k, v in settings if v) @@ -533,7 +565,7 @@ def test_toolchain_win_multi(self): client.run("install . %s -s build_type=%s -s arch=%s -s compiler.runtime=%s -if=conan" " -o hello:shared=%s" % (settings, build_type, arch, runtime, shared)) - vs_path = vs_installation_path("15") + vs_path = vs_installation_path(self.vs_version) vcvars_path = os.path.join(vs_path, "VC/Auxiliary/Build/vcvarsall.bat") for build_type, arch, shared in configs: @@ -548,16 +580,16 @@ def test_toolchain_win_multi(self): '"%s" x64 && msbuild "MyProject.sln" /p:Configuration=%s ' '/p:Platform=%s ' % (vcvars_path, configuration, platform_arch)) client.run_command(cmd) - self.assertIn("Visual Studio 2017", client.out) + self.assertIn("Visual Studio {ide_year}".format(ide_year=self.ide_year), client.out) self.assertIn("[vcvarsall.bat] Environment initialized for: 'x64'", client.out) self._run_app(client, arch, build_type, shared) - check_exe_run(client.out, "main", "msvc", "19.1", build_type, arch, "17", + check_exe_run(client.out, "main", "msvc", self.msvc_version, build_type, arch, "17", {"DEFINITIONS_BOTH": "True", "DEFINITIONS_CONFIG": build_type}) new_cmd = "conan\\%s\\%s\\MyApp.exe" % (arch, configuration) - vcvars = vcvars_command(version="15", architecture="amd64") + vcvars = vcvars_command(version=self.vs_version, architecture="amd64") cmd = ('%s && dumpbin /dependents "%s"' % (vcvars, new_cmd)) client.run_command(cmd) if shared: diff --git a/conans/test/functional/toolchains/microsoft/test_msbuilddeps.py b/conans/test/functional/toolchains/microsoft/test_msbuilddeps.py index 9dba95df736..bcbdcfb48cf 100644 --- a/conans/test/functional/toolchains/microsoft/test_msbuilddeps.py +++ b/conans/test/functional/toolchains/microsoft/test_msbuilddeps.py @@ -4,11 +4,13 @@ import unittest import pytest +from parameterized import parameterized_class from conans.test.assets.genconanfile import GenConanfile from conans.test.assets.pkg_cmake import pkg_cmake from conans.test.assets.sources import gen_function_cpp, gen_function_h from conans.test.assets.visual_project_files import get_vs_project_files +from conans.test.conftest import tools_locations from conans.test.utils.tools import TestClient sln_file = r""" @@ -396,6 +398,12 @@ """ +vs_versions = [{"vs_version": "15", "msvc_version": "19.1", "ide_year": "2017", "toolset": "v141"}] + +if "17" in tools_locations['visual_studio'] and not tools_locations['visual_studio']['17'].get('disabled', False): + vs_versions.append({"vs_version": "17", "msvc_version": "19.3", "ide_year": "2022", "toolset": "v143"}) + +@parameterized_class(vs_versions) @pytest.mark.tool_visual_studio @pytest.mark.skipif(platform.system() != "Windows", reason="Requires MSBuild") class MSBuildGeneratorTest(unittest.TestCase): @@ -470,8 +478,9 @@ class Pkg(ConanFile): """) client.save({"conanfile.py": conanfile}) - client.run('install . -s os=Windows -s compiler="Visual Studio" -s compiler.version=15' - ' -s compiler.runtime=MD') + client.run('install . -s os=Windows -s compiler="Visual Studio" ' + '-s compiler.version={vs_version}' + ' -s compiler.runtime=MD'.format(vs_version=self.vs_version)) self.assertIn("conanfile.py: Generator 'MSBuildDeps' calling 'generate()'", client.out) props = client.load("conan_pkg_release_x64.props") self.assertIn('', props) @@ -508,12 +517,15 @@ def generate(self): """) client.save({"conanfile.py": conanfile}) - client.run('install . -s os=Windows -s compiler="Visual Studio" -s compiler.version=15' - ' -s compiler.runtime=MD') + client.run('install . -s os=Windows -s compiler="Visual Studio" ' + '-s compiler.version={vs_version}' + ' -s compiler.runtime=MD'.format(vs_version=self.vs_version)) props = client.load("conan_pkg_myrelease_myx86_64.props") self.assertIn('', props) - client.run('install . -s os=Windows -s compiler="Visual Studio" -s compiler.version=15' - ' -s compiler.runtime=MD -s arch=x86 -s build_type=Debug') + client.run('install . -s os=Windows -s compiler="Visual Studio" ' + '-s compiler.version={vs_version}' + ' -s compiler.runtime=MD -s arch=x86 ' + '-s build_type=Debug'.format(vs_version=self.vs_version)) props = client.load("conan_pkg_mydebug_myx86.props") self.assertIn('', props) props = client.load("conan_pkg.props") @@ -538,13 +550,15 @@ def generate(self): """) client.save({"conanfile.py": conanfile}) - client.run('install . -s os=Windows -s compiler="Visual Studio" -s compiler.version=15' - ' -s compiler.runtime=MD', assert_error=True) + client.run('install . -s os=Windows -s compiler="Visual Studio"' + ' -s compiler.version={vs_version}' + ' -s compiler.runtime=MD'.format(vs_version=self.vs_version), assert_error=True) self.assertIn("MSBuildDeps.configuration is None, it should have a value", client.out) client.save({"conanfile.py": conanfile.replace("configuration", "platform")}) - client.run('install . -s os=Windows -s compiler="Visual Studio" -s compiler.version=15' - ' -s compiler.runtime=MD', assert_error=True) + client.run('install . -s os=Windows -s compiler="Visual Studio"' + ' -s compiler.version={vs_version}' + ' -s compiler.runtime=MD'.format(vs_version=self.vs_version), assert_error=True) self.assertIn("MSBuildDeps.platform is None, it should have a value", client.out) def test_install_transitive(self): @@ -684,10 +698,19 @@ def build(self): assert "CAExcludePath" not in depb -@pytest.mark.tool_visual_studio +@pytest.mark.tool_visual_studio(version="15") +@pytest.mark.tool_cmake +@pytest.mark.skipif(platform.system() != "Windows", reason="Requires MSBuild") +def test_build_vs_project_with_a_vs2017(): + check_build_vs_project_with_a("15") + +@pytest.mark.tool_visual_studio(version="17") @pytest.mark.tool_cmake @pytest.mark.skipif(platform.system() != "Windows", reason="Requires MSBuild") -def test_build_vs_project_with_a(): +def test_build_vs_project_with_a_vs2022(): + check_build_vs_project_with_a("17") + +def check_build_vs_project_with_a(vs_version): client = TestClient() client.save({"conanfile.py": GenConanfile()}) client.run("create . updep.pkg.team/0.1@") @@ -726,7 +749,8 @@ def package_info(self): "CMakeLists.txt": cmake, "hello.cpp": hello_cpp, "hello.h": hello_h}) - client.run('create . mydep.pkg.team/0.1@ -s compiler="Visual Studio" -s compiler.version=15') + client.run('create . mydep.pkg.team/0.1@ -s compiler="Visual Studio"' + ' -s compiler.version={vs_version}'.format(vs_version=vs_version)) consumer = textwrap.dedent(""" from conans import ConanFile @@ -749,7 +773,8 @@ def build(self): new = old + ''.format(props=props) files["MyProject/MyProject.vcxproj"] = files["MyProject/MyProject.vcxproj"].replace(old, new) client.save(files, clean_first=True) - client.run('install . -s compiler="Visual Studio" -s compiler.version=15') + client.run('install . -s compiler="Visual Studio"' + ' -s compiler.version={vs_version}'.format(vs_version=vs_version)) client.run("build .") client.run_command(r"x64\Release\MyProject.exe") assert "hello: Release!" in client.out @@ -757,17 +782,26 @@ def build(self): # assert "main: Release!" in client.out -@pytest.mark.tool_visual_studio +@pytest.mark.tool_visual_studio(version="15") +@pytest.mark.tool_cmake +@pytest.mark.skipif(platform.system() != "Windows", reason="Requires MSBuild") +def test_build_vs_project_with_test_requires_vs2017(): + check_build_vs_project_with_test_requires("15") + +@pytest.mark.tool_visual_studio(version="17") @pytest.mark.tool_cmake @pytest.mark.skipif(platform.system() != "Windows", reason="Requires MSBuild") -def test_build_vs_project_with_test_requires(): +def test_build_vs_project_with_test_requires_vs2022(): + check_build_vs_project_with_test_requires("17") + +def check_build_vs_project_with_test_requires(vs_version): client = TestClient() client.save(pkg_cmake("updep.pkg.team", "0.1")) - client.run("create . -s compiler.version=15") + client.run("create . -s compiler.version={vs_version}".format(vs_version=vs_version)) client.save(pkg_cmake("mydep.pkg.team", "0.1", requires=["updep.pkg.team/0.1"]), clean_first=True) - client.run("create . -s compiler.version=15") + client.run("create . -s compiler.version={vs_version}".format(vs_version=vs_version)) consumer = textwrap.dedent(""" from conans import ConanFile @@ -793,7 +827,7 @@ def build(self): new = old + ''.format(props=props) files["MyProject/MyProject.vcxproj"] = files["MyProject/MyProject.vcxproj"].replace(old, new) client.save(files, clean_first=True) - client.run('install . -s compiler.version=15') + client.run('install . -s compiler.version={vs_version}'.format(vs_version=vs_version)) client.run("build .") client.run_command(r"x64\Release\MyProject.exe") assert "mydep_pkg_team: Release!" in client.out diff --git a/conans/test/functional/utils.py b/conans/test/functional/utils.py index 365d468b1ff..7d69b0ee76b 100644 --- a/conans/test/functional/utils.py +++ b/conans/test/functional/utils.py @@ -14,7 +14,7 @@ def check_vs_runtime(artifact, client, vs_version, build_type, architecture="amd assert "MSVC" not in client.out assert "VCRUNTIME" not in client.out else: - if vs_version == "15": + if vs_version in ["15", "16", "17"]: # UCRT debug = "D" if build_type == "Debug" else "" assert "MSVCP140{}.dll".format(debug) in client.out assert "VCRUNTIME140{}.dll".format(debug) in client.out diff --git a/conans/test/unittests/client/build/compiler_id_test.py b/conans/test/unittests/client/build/compiler_id_test.py index a34c091a5f0..34dabe8ce02 100644 --- a/conans/test/unittests/client/build/compiler_id_test.py +++ b/conans/test/unittests/client/build/compiler_id_test.py @@ -100,7 +100,13 @@ def test_suncc(self): ("MSC_CMD_FLAGS=-D_MSC_VER=1924", 16, 4, 0), ("MSC_CMD_FLAGS=-D_MSC_VER=1925", 16, 5, 0), ("MSC_CMD_FLAGS=-D_MSC_VER=1926", 16, 6, 0), - ("MSC_CMD_FLAGS=-D_MSC_VER=1927", 16, 7, 0)]) + ("MSC_CMD_FLAGS=-D_MSC_VER=1927", 16, 7, 0), + ("MSC_CMD_FLAGS=-D_MSC_VER=1928", 16, 8, 0), + ("MSC_CMD_FLAGS=-D_MSC_VER=1928 -D_MSC_FULL_VER=192829500", 16, 9, 0), + ("MSC_CMD_FLAGS=-D_MSC_VER=1929", 16, 10, 0), + ("MSC_CMD_FLAGS=-D_MSC_VER=1929 -D_MSC_FULL_VER=192930100", 16, 11, 0), + ("MSC_CMD_FLAGS=-D_MSC_VER=1930", 17, 0, 0), + ]) def test_msvc(self, line, major, minor, patch): runner = RunnerMock() runner.output = line diff --git a/conans/test/unittests/client/build/cpp_std_flags_test.py b/conans/test/unittests/client/build/cpp_std_flags_test.py index 868bef5d7e8..078663845e2 100644 --- a/conans/test/unittests/client/build/cpp_std_flags_test.py +++ b/conans/test/unittests/client/build/cpp_std_flags_test.py @@ -223,7 +223,8 @@ def test_visual_cppstd_flags(self): self.assertEqual(_make_cppstd_flag("Visual Studio", "17", "11"), None) self.assertEqual(_make_cppstd_flag("Visual Studio", "17", "14"), '/std:c++14') self.assertEqual(_make_cppstd_flag("Visual Studio", "17", "17"), '/std:c++17') - self.assertEqual(_make_cppstd_flag("Visual Studio", "17", "20"), '/std:c++latest') + self.assertEqual(_make_cppstd_flag("Visual Studio", "17", "20"), '/std:c++20') + self.assertEqual(_make_cppstd_flag("Visual Studio", "17", "23"), '/std:c++latest') def test_visual_cppstd_defaults(self): self.assertEqual(_make_cppstd_default("Visual Studio", "11"), None) diff --git a/conans/test/unittests/client/build/msbuild_test.py b/conans/test/unittests/client/build/msbuild_test.py index ec2d4962aa9..0fa1e7bcbde 100644 --- a/conans/test/unittests/client/build/msbuild_test.py +++ b/conans/test/unittests/client/build/msbuild_test.py @@ -92,7 +92,8 @@ def test_error_targets_argument(self): with self.assertRaises(TypeError): msbuild.get_command("dummy.sln", targets="sometarget") - @parameterized.expand([("16", "v142"), + @parameterized.expand([("17", "v143"), + ("16", "v142"), ("15", "v141"), ("14", "v140"), ("12", "v120"), @@ -110,7 +111,8 @@ def test_default_toolset(self, compiler_version, expected_toolset): command = msbuild.get_command("project_should_flags_test_file.sln") self.assertIn('/p:PlatformToolset="%s"' % expected_toolset, command) - @parameterized.expand([("v142",), + @parameterized.expand([("v143",), + ("v142",), ("v141",), ("v140",), ("v120",), diff --git a/conans/test/unittests/model/info/vs_toolset_compatible_test.py b/conans/test/unittests/model/info/vs_toolset_compatible_test.py index d62e346ebdc..f91597eed6b 100644 --- a/conans/test/unittests/model/info/vs_toolset_compatible_test.py +++ b/conans/test/unittests/model/info/vs_toolset_compatible_test.py @@ -11,7 +11,8 @@ class VSToolsetCompatibleTest(unittest.TestCase): - @parameterized.expand([("15", "v142", "16"), + @parameterized.expand([("16", "v143", "17"), + ("15", "v142", "16"), ("14", "v141", "15"), ("15", "v140", "14"), ("11", "v120", "12"), diff --git a/conans/test/unittests/tools/cmake/test_cmaketoolchain.py b/conans/test/unittests/tools/cmake/test_cmaketoolchain.py index d9a285e2e30..d609c17cb42 100644 --- a/conans/test/unittests/tools/cmake/test_cmaketoolchain.py +++ b/conans/test/unittests/tools/cmake/test_cmaketoolchain.py @@ -165,3 +165,30 @@ def test_osx_deployment_target(conanfile_apple): toolchain = CMakeToolchain(conanfile_apple) content = toolchain.content assert 'set(CMAKE_OSX_DEPLOYMENT_TARGET "10.15" CACHE STRING "")' in content + +@pytest.fixture +def conanfile_msvc(): + c = ConanFile(Mock(), None) + c.settings = "os", "compiler", "build_type", "arch" + c.initialize(Settings({"os": ["Windows"], + "compiler": {"msvc": {"version": ["19.3"], "cppstd": ["20"]}}, + "build_type": ["Release"], + "arch": ["x86"]}), EnvValues()) + c.settings.build_type = "Release" + c.settings.arch = "x86" + c.settings.compiler = "msvc" + c.settings.compiler.version = "19.3" + c.settings.compiler.cppstd = "20" + c.settings.os = "Windows" + c.conf = Conf() + c.folders.set_base_generators(".") + c._conan_node = Mock() + c._conan_node.dependencies = [] + return c + +def test_toolset(conanfile_msvc): + toolchain = CMakeToolchain(conanfile_msvc) + assert 'CMAKE_GENERATOR_TOOLSET "v143"' in toolchain.content + assert 'Visual Studio 17 2022' in toolchain.generator + assert 'CMAKE_CXX_STANDARD 20' in toolchain.content + diff --git a/conans/test/unittests/tools/microsoft/test_msbuild.py b/conans/test/unittests/tools/microsoft/test_msbuild.py index d61c1827e9b..acf690651c3 100644 --- a/conans/test/unittests/tools/microsoft/test_msbuild.py +++ b/conans/test/unittests/tools/microsoft/test_msbuild.py @@ -1,8 +1,14 @@ +import mock +import os import textwrap +from mock import Mock -from conan.tools.microsoft import MSBuild +from conan.tools.microsoft import MSBuild, MSBuildToolchain from conans.model.conf import ConfDefinition +from conans.model.env_info import EnvValues from conans.test.utils.mocks import ConanFileMock, MockSettings +from conans.tools import load +from conans import ConanFile, Settings def test_msbuild_cpu_count(): @@ -25,3 +31,43 @@ def test_msbuild_cpu_count(): cmd = msbuild.command('project.sln') assert '/m:23' in cmd + +def test_msbuild_toolset(): + settings = Settings({"build_type": ["Release"], + "compiler": {"msvc": {"version": ["19.3"]}}, + "os": ["Windows"], + "arch": ["x86_64"]}) + conanfile = ConanFile(Mock(), None) + conanfile.settings = "os", "compiler", "build_type", "arch" + conanfile.initialize(settings, EnvValues()) + conanfile.settings.build_type = "Release" + conanfile.settings.compiler = "msvc" + conanfile.settings.compiler.version = "19.3" + conanfile.settings.os = "Windows" + conanfile.settings.arch = "x86_64" + + msbuild = MSBuildToolchain(conanfile) + assert 'v143' in msbuild.toolset + +def test_msbuild_standard(): + settings = Settings({"build_type": ["Release"], + "compiler": {"msvc": {"version": ["19.3"], "cppstd": ["20"]}}, + "os": ["Windows"], + "arch": ["x86_64"]}) + conanfile = ConanFile(Mock(), None) + conanfile.folders.set_base_generators(".") + conanfile.install_folder = os.getcwd() + conanfile.conf = ConfDefinition() + conanfile.settings = "os", "compiler", "build_type", "arch" + conanfile.initialize(settings, EnvValues()) + conanfile.settings.build_type = "Release" + conanfile.settings.compiler = "msvc" + conanfile.settings.compiler.version = "19.3" + conanfile.settings.compiler.cppstd = "20" + conanfile.settings.os = "Windows" + conanfile.settings.arch = "x86_64" + + msbuild = MSBuildToolchain(conanfile) + with mock.patch("conan.tools.microsoft.visual.vcvars_path", mock.MagicMock(return_value=".")): + msbuild.generate() + assert 'stdcpp20' in load('conantoolchain_release_x64.props') diff --git a/conans/test/unittests/util/build_sln_command_test.py b/conans/test/unittests/util/build_sln_command_test.py index d2897deb9e6..c5481da0ba0 100644 --- a/conans/test/unittests/util/build_sln_command_test.py +++ b/conans/test/unittests/util/build_sln_command_test.py @@ -179,6 +179,7 @@ def test_properties_file(self): self.assertTrue(command.startswith('msbuild "dummy.sln" /p:Configuration="Debug" ' '/p:UseEnv=false ' '/p:Platform="ARM" ' + '/p:PlatformToolset="v143" ' '/verbosity:minimal ' '/p:ForceImportBeforeCppTargets='), command) path_tmp = command.split("/p:ForceImportBeforeCppTargets=")[1][1:-1] # remove quotes diff --git a/conans/test/unittests/util/msvs_toolset_test.py b/conans/test/unittests/util/msvs_toolset_test.py index 08e92bba60e..d75937c4d25 100644 --- a/conans/test/unittests/util/msvs_toolset_test.py +++ b/conans/test/unittests/util/msvs_toolset_test.py @@ -11,7 +11,8 @@ class MSVCToolsetTest(unittest.TestCase): - @parameterized.expand([("16", "v142"), + @parameterized.expand([("17", "v143"), + ("16", "v142"), ("15", "v141"), ("14", "v140"), ("12", "v120"),