From 2bad8b2156a92607cfa2e7e1e85ca12d784b40fe Mon Sep 17 00:00:00 2001 From: memsharded Date: Wed, 1 Mar 2023 00:45:13 +0100 Subject: [PATCH 1/2] fix msvc cppstd checks --- conan/tools/build/cppstd.py | 6 ++++-- conans/client/profile_loader.py | 3 ++- conans/test/unittests/tools/build/test_cppstd.py | 5 +++-- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/conan/tools/build/cppstd.py b/conan/tools/build/cppstd.py index bdf08ca3925..381f66805d5 100644 --- a/conan/tools/build/cppstd.py +++ b/conan/tools/build/cppstd.py @@ -205,9 +205,11 @@ def _msvc_supported_cppstd(version): """ [14, 17, 20, 23] """ - if version < "190": + if version < "190": # pre VS 2015 return [] - if version < "191": + if version < "191": # VS 2015 + return ["14"] + if version < "192": # VS 2017 return ["14", "17"] if version < "193": return ["14", "17", "20"] diff --git a/conans/client/profile_loader.py b/conans/client/profile_loader.py index 6c51598f323..b94f9beaaf9 100644 --- a/conans/client/profile_loader.py +++ b/conans/client/profile_loader.py @@ -68,7 +68,8 @@ def _error(compiler, cppstd, min_version, version): "14": "5.1", "11": "4.5"}.get(cppstd) elif compiler == "msvc": - mver = {"20": "193", + mver = {"23": "193", + "20": "192", "17": "191", "14": "190"}.get(cppstd) if mver and version < mver: diff --git a/conans/test/unittests/tools/build/test_cppstd.py b/conans/test/unittests/tools/build/test_cppstd.py index 2be74004ea5..b3d24c10af2 100644 --- a/conans/test/unittests/tools/build/test_cppstd.py +++ b/conans/test/unittests/tools/build/test_cppstd.py @@ -79,8 +79,9 @@ def test_supported_cppstd_apple_clang(compiler, compiler_version, values): @pytest.mark.parametrize("compiler,compiler_version,values", [ ("msvc", "180", []), - ("msvc", "190", ['14', '17']), - ("msvc", "191", ['14', '17', '20']), + ("msvc", "190", ['14']), + ("msvc", "191", ['14', '17']), + ("msvc", "192", ['14', '17', '20']), ("msvc", "193", ['14', '17', '20', '23']), ]) def test_supported_cppstd_msvc(compiler, compiler_version, values): From 62410e3759e5b5a3a3a2eb41dc1508208eaed691 Mon Sep 17 00:00:00 2001 From: memsharded Date: Wed, 1 Mar 2023 13:46:29 +0100 Subject: [PATCH 2/2] comments --- conan/tools/build/cppstd.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/conan/tools/build/cppstd.py b/conan/tools/build/cppstd.py index 381f66805d5..423c0a279f5 100644 --- a/conan/tools/build/cppstd.py +++ b/conan/tools/build/cppstd.py @@ -203,6 +203,10 @@ def _gcc_supported_cppstd(version): def _msvc_supported_cppstd(version): """ + https://learn.microsoft.com/en-us/cpp/build/reference/std-specify-language-standard-version?view=msvc-170 + - /std:c++14 starting in Visual Studio 2015 Update 3 (190) + - /std:c++17 starting in Visual Studio 2017 version 15.3. (191) + - /std:c++20 starting in Visual Studio 2019 version 16.11 (192) [14, 17, 20, 23] """ if version < "190": # pre VS 2015