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

Feature: Visual Studio 2022 #9370

Merged
merged 22 commits into from
Aug 30, 2021
Merged
Show file tree
Hide file tree
Changes from all 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
12 changes: 10 additions & 2 deletions conan/tools/_compilers.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,15 +152,19 @@ def _cppstd_visualstudio(visual_version, cppstd):
v14 = None
v17 = None
v20 = None
v23 = None

if Version(visual_version) >= "14":
v14 = "c++14"
v17 = "c++latest"
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


Expand All @@ -169,15 +173,19 @@ def _cppstd_msvc(visual_version, cppstd):
v14 = None
v17 = None
v20 = None
v23 = None

if Version(visual_version) >= "19.0":
v14 = "c++14"
v17 = "c++latest"
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


Expand Down
3 changes: 2 additions & 1 deletion conan/tools/cmake/toolchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
9 changes: 6 additions & 3 deletions conan/tools/microsoft/toolchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 \
Expand All @@ -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",
Expand Down
6 changes: 4 additions & 2 deletions conan/tools/microsoft/visual.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion conans/client/build/cmake_flags.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
12 changes: 10 additions & 2 deletions conans/client/build/cppstd_flags.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,15 +103,19 @@ def _cppstd_visualstudio(visual_version, cppstd):
v14 = None
v17 = None
v20 = None
v23 = None

if Version(visual_version) >= "14":
v14 = "c++14"
v17 = "c++latest"
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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These changes are missing in conan.tools._compilers, please make sure they are done there too.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added

return "/std:%s" % flag if flag else None


Expand All @@ -120,15 +124,19 @@ def _cppstd_msvc(visual_version, cppstd):
v14 = None
v17 = None
v20 = None
v23 = None

if Version(visual_version) >= "19.0":
v14 = "c++14"
v17 = "c++latest"
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


Expand Down
9 changes: 5 additions & 4 deletions conans/client/conf/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
13 changes: 12 additions & 1 deletion conans/client/conf/compiler_id.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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:
Expand Down
2 changes: 2 additions & 0 deletions conans/client/generators/cmake_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
121 changes: 120 additions & 1 deletion conans/client/migrations_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@memsharded there is some important thing, which concerns me a lot. it's not directly related to VS2022, but to msvc compiler versioning scheme in general.
I just realized it than I've seen we maybe need to add 19.29 to the list.
check out https://docs.microsoft.com/en-us/cpp/preprocessor/predefined-macros?view=vs-2019
TLDR: _MSC_VER 19.28 maps to the two versions (16.8 and 16.9), and 19.30 maps to the two versions as well (16.10 and 16.11)
our current versioning scheme won't be able to express that.
maybe we need to create a new issue and discuss if we want to change? since msvc is experimental, it's not late.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But we are ok with msvc.version right? I mean if 19.28 maps both to 16.8 and 16.9 means that both versions "use the same compiler version", so the model for msvc is good. The reverse mapping can choose the version we want. How do you think this could affect? @SSE4

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it may hit some users who use LTTG and binaries aren't compatible for 16.8 vs 16.9
perhaps, they will need to add more sub-settings, like 19.28.29500?
more info is by links from #3573 (comment):
https://developercommunity.visualstudio.com/t/the-169-cc-compiler-still-uses-the-same-version-nu/1335194#T-N1337120
https://developercommunity.visualstudio.com/t/how-to-select-vs-168-compiler-with-vcvars-after-up/1359197?from=email

it's irrelevant for vs2022 anyway, but maybe we can discuss if it's an issue to be addressed in conan.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I see. What a mess...

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
"""
9 changes: 6 additions & 3 deletions conans/client/tools/win.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand All @@ -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",
Expand Down
3 changes: 2 additions & 1 deletion conans/model/info.py
Original file line number Diff line number Diff line change
Expand Up @@ -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":
Expand Down
4 changes: 2 additions & 2 deletions conans/test/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading