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

Adding new conf to allow specifying compiler update when compiler.version=193 with VS 17.10 #16332

Merged
merged 4 commits into from
May 28, 2024
Merged
Show file tree
Hide file tree
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
5 changes: 3 additions & 2 deletions conan/tools/cmake/toolchain/blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -810,9 +810,10 @@ def get_toolset(generator, conanfile):
toolset = settings.get_safe("compiler.toolset")
if toolset is None:
compiler_version = str(settings.compiler.version)
compiler_update = str(settings.compiler.update)
msvc_update = conanfile.conf.get("tools.microsoft:msvc_update")
compiler_update = msvc_update or settings.get_safe("compiler.update")
toolset = msvc_version_to_toolset_version(compiler_version)
if compiler_update != "None": # It is full one(19.28), not generic 19.2X
if compiler_update is not None: # It is full one(19.28), not generic 19.2X
# The equivalent of compiler 19.26 is toolset 14.26
toolset += ",version=14.{}{}".format(compiler_version[-1], compiler_update)
elif compiler == "clang":
Expand Down
3 changes: 2 additions & 1 deletion conan/tools/microsoft/visual.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ def check_min_vs(conanfile, version, raise_invalid=True):
"11": "170"}.get(compiler_version)
elif compiler == "msvc":
compiler_version = conanfile.settings.get_safe("compiler.version")
compiler_update = conanfile.settings.get_safe("compiler.update")
msvc_update = conanfile.conf.get("tools.microsoft:msvc_update")
compiler_update = msvc_update or conanfile.settings.get_safe("compiler.update")
if compiler_version and compiler_update is not None:
compiler_version += ".{}".format(compiler_update)

Expand Down
1 change: 1 addition & 0 deletions conans/model/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@
"tools.meson.mesontoolchain:backend": "Any Meson backend: ninja, vs, vs2010, vs2012, vs2013, vs2015, vs2017, vs2019, xcode",
"tools.meson.mesontoolchain:extra_machine_files": "List of paths for any additional native/cross file references to be appended to the existing Conan ones",
"tools.microsoft:winsdk_version": "Use this winsdk_version in vcvars",
"tools.microsoft:msvc_update": "Force the specific update irrespective of compiler.update (CMakeToolchain and VCVars)",
"tools.microsoft.msbuild:vs_version": "Defines the IDE version (15, 16, 17) when using the msvc compiler. Necessary if compiler.version specifies a toolset that is not the IDE default",
"tools.microsoft.msbuild:max_cpu_count": "Argument for the /m when running msvc to build parallel projects",
"tools.microsoft.msbuild:installation_path": "VS install path, to avoid auto-detect via vswhere, like C:/Program Files (x86)/Microsoft Visual Studio/2019/Community. Use empty string to disable",
Expand Down
18 changes: 17 additions & 1 deletion conans/test/unittests/tools/cmake/test_cmaketoolchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ def conanfile_msvc():
c.settings.build_type = "Release"
c.settings.arch = "x86"
c.settings.compiler = "msvc"
c.settings.compiler.version = "193"
c.settings.compiler.version = "194"
c.settings.compiler.cppstd = "20"
c.settings.os = "Windows"
c.settings_build = c.settings
Expand All @@ -221,11 +221,27 @@ def test_toolset(conanfile_msvc):


def test_toolset_update_version(conanfile_msvc):
conanfile_msvc.settings.compiler.version = "193"
conanfile_msvc.settings.compiler.update = "8"
toolchain = CMakeToolchain(conanfile_msvc)
assert 'set(CMAKE_GENERATOR_TOOLSET "v143,version=14.38" CACHE STRING "" FORCE)' in toolchain.content


def test_toolset_update_version_conf(conanfile_msvc):
conanfile_msvc.settings.compiler.version = "193"
conanfile_msvc.conf.define("tools.microsoft:msvc_update", "7")
toolchain = CMakeToolchain(conanfile_msvc)
assert 'set(CMAKE_GENERATOR_TOOLSET "v143,version=14.37" CACHE STRING "" FORCE)' in toolchain.content


def test_toolset_update_version_forced_conf(conanfile_msvc):
conanfile_msvc.settings.compiler.version = "193"
conanfile_msvc.settings.compiler.update = "8"
conanfile_msvc.conf.define("tools.microsoft:msvc_update", "7")
toolchain = CMakeToolchain(conanfile_msvc)
assert 'set(CMAKE_GENERATOR_TOOLSET "v143,version=14.37" CACHE STRING "" FORCE)' in toolchain.content


def test_toolset_update_version_overflow(conanfile_msvc):
# https://github.com/conan-io/conan/issues/15583
conanfile_msvc.settings.compiler.version = "194"
Expand Down
45 changes: 45 additions & 0 deletions test/conftest_user.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
tools_locations = {
czoido marked this conversation as resolved.
Show resolved Hide resolved
'cmake': {
"default": "3.25",
"3.25": {},
"3.23": {"path": {'Windows': r'C:\ws\cmake\cmake-3.23.1-windows-x86_64\bin'}}
},
'ninja': {
"1.10.2": {"path": {'Windows': 'C:/ws/ninja/ninja1.10.2'}}
},
'msys2': {
"platform": "Windows",
"default": "system",
"exe": "make",
"system": {"path": {'Windows': "C:/ws/msys64/usr/bin"}},
},
'mingw64': {
"platform": "Windows",
"default": "system",
"exe": "mingw32-make",
"system": {"path": {'Windows': "C:/ws/msys64/mingw64/bin"}},
},
"clang": {
"13": {"path": {'Windows': r'C:/ws/LLVM/clang13/bin'}},
"16": {"path": {'Windows': r'C:/ws/LLVM/clang16/bin'}},
"disabled": False
},
'visual_studio': {"default": "15",
"15": {},
"16": {"disabled": False},
"17": {}},
'msys2_clang64': {
"disabled": False,
"platform": "Windows",
"default": "system",
"exe": "clang",
"system": {"path": {'Windows': "C:/ws/msys64/clang64/bin"}},
},
'msys2_mingw64_clang64': {
"disabled": False,
"platform": "Windows",
"default": "system",
"exe": "clang",
"system": {"path": {'Windows': "C:/ws/msys64/mingw64/bin"}},
},
}