diff options
| author | SirLynix <[email protected]> | 2024-06-01 17:01:40 +0200 |
|---|---|---|
| committer | SirLynix <[email protected]> | 2024-06-01 17:01:40 +0200 |
| commit | 91fd4825abfbe66407ef1a248038411628786723 (patch) | |
| tree | c588d5cd24caedfc7cd79ca8778f2dd072f1fd93 | |
| parent | 45b3a712189d2cffe1dbc900b4a4cca453140246 (diff) | |
Don't use v144 toolset for VS 17.10
| -rw-r--r-- | xmake/modules/package/tools/cmake.lua | 23 | ||||
| -rw-r--r-- | xmake/modules/private/utils/toolchain.lua | 16 | ||||
| -rw-r--r-- | xmake/modules/private/utils/upgrade_vsproj.lua | 15 | ||||
| -rw-r--r-- | xmake/plugins/project/vstudio/impl/vs201x_vcxproj.lua | 10 |
4 files changed, 21 insertions, 43 deletions
diff --git a/xmake/modules/package/tools/cmake.lua b/xmake/modules/package/tools/cmake.lua index 681bbf209..03cc3f665 100644 --- a/xmake/modules/package/tools/cmake.lua +++ b/xmake/modules/package/tools/cmake.lua @@ -288,27 +288,6 @@ function _get_cmake_version() return cmake_version end --- get vs toolset -function _get_vs_toolset(package) - local toolset_ver = nil - local vs_toolset = _get_msvc(package):config("vs_toolset") or config.get("vs_toolset") - if vs_toolset then - local verinfo = vs_toolset:split('%.') - if #verinfo >= 2 then - toolset_ver = "v" .. verinfo[1] .. (verinfo[2]:sub(1, 1) or "0") - end - end - -- cmake does not support vs toolset v144 below 3.29.3, we can only use v143 - -- @see https://github.com/xmake-io/xmake/issues/4772 - if toolset_ver and toolset_ver >= "v144" then - local cmake_version = _get_cmake_version() - if cmake_version and cmake_version:le("3.29.3") then - toolset_ver = "v143" - end - end - return toolset_ver -end - -- insert configs from envs function _insert_configs_from_envs(configs, envs, opt) opt = opt or {} @@ -366,7 +345,7 @@ function _get_configs_for_windows(package, configs, opt) else table.insert(configs, "x64") end - local vs_toolset = _get_vs_toolset(package) + local vs_toolset = toolchain_utils.get_vs_toolset_ver(_get_msvc(package):config("vs_toolset") or config.get("vs_toolset")) if vs_toolset then table.insert(configs, "-DCMAKE_GENERATOR_TOOLSET=" .. vs_toolset) end diff --git a/xmake/modules/private/utils/toolchain.lua b/xmake/modules/private/utils/toolchain.lua index 686c06ffd..93fd81fcf 100644 --- a/xmake/modules/private/utils/toolchain.lua +++ b/xmake/modules/private/utils/toolchain.lua @@ -31,3 +31,19 @@ function is_compatible_with_host(name) end end +-- toolset v144 doesn't exist and will cause issues with cmake/vs generation +local vs_toolset_mapping = { + ["v144"] = "v143" +} + +function get_vs_toolset_ver(vs_toolset) + local toolset_ver + if vs_toolset then + local verinfo = vs_toolset:split('%.') + if #verinfo >= 2 then + toolset_ver = "v" .. verinfo[1] .. (verinfo[2]:sub(1, 1) or "0") + toolset_ver = vs_toolset_mapping[toolset_ver] or toolset_ver + end + end + return toolset_ver +end diff --git a/xmake/modules/private/utils/upgrade_vsproj.lua b/xmake/modules/private/utils/upgrade_vsproj.lua index d70bf4e02..7f17d42c1 100644 --- a/xmake/modules/private/utils/upgrade_vsproj.lua +++ b/xmake/modules/private/utils/upgrade_vsproj.lua @@ -22,6 +22,7 @@ import("core.base.option") import("core.tool.toolchain") import("plugins.project.vstudio.impl.vsinfo", {rootdir = os.programdir()}) +import("private.utils.toolchain", {alias = "toolchain_utils"}) -- the options local options = { @@ -31,18 +32,6 @@ local options = { , {nil, "vs_projectfiles", "vs", nil, "Set the solution or project files." } } --- get toolset version -function _get_toolset_ver(vs_toolset) - local toolset_ver = nil - if vs_toolset then - local verinfo = vs_toolset:split('%.') - if #verinfo >= 2 then - toolset_ver = "v" .. verinfo[1] .. (verinfo[2]:sub(1, 1) or "0") - end - end - return toolset_ver -end - -- upgrade *.sln function _upgrade_sln(projectfile, opt) opt = opt or {} @@ -61,7 +50,7 @@ function _upgrade_vcxproj(projectfile, opt) local vs_version = opt.vs or msvc:config("vs") local vs_info = assert(vsinfo(tonumber(vs_version)), "unknown vs version!") local vs_sdkver = opt.vs_sdkver or msvc:config("vs_sdkver") or vs_info.sdk_version - local vs_toolset = _get_toolset_ver(opt.vs_toolset or msvc:config("vs_toolset")) or vs_info.toolset_version + local vs_toolset = toolchain_utils.get_vs_toolset_ver(opt.vs_toolset or msvc:config("vs_toolset")) or vs_info.toolset_version local vs_toolsver = vs_info.project_version io.gsub(projectfile, "<PlatformToolset>v%d+</PlatformToolset>", "<PlatformToolset>" .. vs_toolset .. "</PlatformToolset>") diff --git a/xmake/plugins/project/vstudio/impl/vs201x_vcxproj.lua b/xmake/plugins/project/vstudio/impl/vs201x_vcxproj.lua index 0ae5e78be..109094a55 100644 --- a/xmake/plugins/project/vstudio/impl/vs201x_vcxproj.lua +++ b/xmake/plugins/project/vstudio/impl/vs201x_vcxproj.lua @@ -29,6 +29,7 @@ import("private.utils.batchcmds") import("detect.sdks.find_cuda") import("vsfile") import("vsutils") +import("private.utils.toolchain", {alias = "toolchain_utils"}) function _make_dirs(dir, vcxprojdir) dir = dir:trim() @@ -62,16 +63,9 @@ end -- get toolset version function _get_toolset_ver(targetinfo, vsinfo) - -- get toolset version from vs version - local toolset_ver = nil local vs_toolset = toolchain.load("msvc"):config("vs_toolset") or config.get("vs_toolset") - if vs_toolset then - local verinfo = vs_toolset:split('%.') - if #verinfo >= 2 then - toolset_ver = "v" .. verinfo[1] .. (verinfo[2]:sub(1, 1) or "0") - end - end + local toolset_ver = toolchain_utils.get_vs_toolset_ver(vs_toolset) if not toolset_ver then toolset_ver = vsinfo.toolset_version end |
