Skip to content

Commit 1f05fb2

Browse files
committed
fix clangcl toolset in latest VS18 (#19289)
1 parent 71077ee commit 1f05fb2

File tree

3 files changed

+32
-4
lines changed

3 files changed

+32
-4
lines changed

conan/internal/default_settings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@
146146
cppstd: [null, 98, gnu98, 11, gnu11, 14, gnu14, 17, gnu17, 20, gnu20, 23, gnu23, 26, gnu26]
147147
runtime: [null, static, dynamic]
148148
runtime_type: [null, Debug, Release]
149-
runtime_version: [null, v140, v141, v142, v143, v144]
149+
runtime_version: [null, v140, v141, v142, v143, v144, v145]
150150
cstd: [null, 99, gnu99, 11, gnu11, 17, gnu17, 23, gnu23]
151151
apple-clang:
152152
version: ["5.0", "5.1", "6.0", "6.1", "7.0", "7.3", "8.0", "8.1", "9.0", "9.1",

conan/tools/cmake/toolchain/blocks.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
from conan.tools.build.flags import architecture_flag, architecture_link_flag, libcxx_flags, threads_flags
1414
from conan.tools.build.cross_building import cross_building
1515
from conan.tools.cmake.toolchain import CONAN_TOOLCHAIN_FILENAME
16-
from conan.tools.cmake.utils import is_multi_configuration, parse_extra_variable
16+
from conan.tools.cmake.utils import is_multi_configuration
1717
from conan.tools.intel import IntelCC
1818
from conan.tools.microsoft.visual import msvc_version_to_toolset_version, msvc_platform_from_arch
1919
from conan.internal.api.install.generators import relativize_path
@@ -1005,11 +1005,11 @@ def get_toolset(generator, conanfile):
10051005
toolset += ",version=14.{}{}".format(compiler_version[-1], compiler_update)
10061006
elif compiler == "clang":
10071007
if generator and "Visual" in generator:
1008-
if "Visual Studio 16" in generator or "Visual Studio 17" in generator:
1008+
if any(f"Visual Studio {v}" in generator for v in ("16", "17", "18")):
10091009
toolset = "ClangCL"
10101010
else:
10111011
raise ConanException("CMakeToolchain with compiler=clang and a CMake "
1012-
"'Visual Studio' generator requires VS16 or VS17")
1012+
"'Visual Studio' generator requires VS16, VS17 or VS18")
10131013
toolset_arch = conanfile.conf.get("tools.cmake.cmaketoolchain:toolset_arch")
10141014
if toolset_arch is not None:
10151015
toolset_arch = "host={}".format(toolset_arch)

test/unittests/tools/cmake/test_cmaketoolchain.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,34 @@ def test_older_msvc_toolset():
351351
assert 'CMAKE_CXX_STANDARD 98' in content
352352

353353

354+
def test_vs_clangcl():
355+
c = ConanFile(None)
356+
c.settings = Settings({"os": ["Windows"],
357+
"compiler": {"clang": {"version": ["20"], "runtime": ["v145"],
358+
"cppstd": ["14"]}},
359+
"build_type": ["Release"],
360+
"arch": ["x86_64"]})
361+
c.settings.build_type = "Release"
362+
c.settings.arch = "x86_64"
363+
c.settings.compiler = "clang"
364+
c.settings.compiler.runtime = "v145"
365+
c.settings.compiler.version = "20"
366+
c.settings.compiler.cppstd = "14"
367+
c.settings.os = "Windows"
368+
c.settings_build = c.settings
369+
c.conf = Conf()
370+
c.conf.define("tools.cmake.cmaketoolchain:generator", "Visual Studio 18")
371+
c.folders.set_base_generators(".")
372+
c._conan_node = Mock()
373+
c._conan_node.dependencies = []
374+
c._conan_node.transitive_deps = {}
375+
c._conan_node.replaced_requires = {}
376+
toolchain = CMakeToolchain(c)
377+
content = toolchain.content
378+
assert 'CMAKE_GENERATOR_TOOLSET "ClangCL"' in content
379+
assert 'CMAKE_CXX_STANDARD 14' in content
380+
381+
354382
def test_older_msvc_toolset_update():
355383
# https://github.com/conan-io/conan/issues/15787
356384
c = ConanFile(None)

0 commit comments

Comments
 (0)