summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2024-06-03 10:09:25 +0800
committerGitHub <[email protected]>2024-06-03 10:09:25 +0800
commit41d35c06605de8b541c13033cc24446f17106068 (patch)
tree75c8ae9c56e2c1bd5c8133f54e9d89106fadf9e6
parent5e4bbe9d314f62fdd6586ff0c3223145517c6507 (diff)
parenta62a73914de453b93a9ccfe38c909d52e155ca61 (diff)
Merge pull request #5176 from SirLynix/vs_toolset_v144
Fix VS toolset v144
-rw-r--r--xmake/modules/package/tools/cmake.lua23
-rw-r--r--xmake/modules/private/utils/toolchain.lua16
-rw-r--r--xmake/modules/private/utils/upgrade_vsproj.lua15
-rw-r--r--xmake/plugins/project/vstudio/impl/vs201x_vcxproj.lua10
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..6297ec8e2 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
+-- get vs toolset version, e.g. v143, v144, ..
+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")
+ end
+
+ -- @see https://github.com/xmake-io/xmake/pull/5176
+ if toolset_ver and toolset_ver == "v144" and vs_toolset:startswith("14.40.") then
+ toolset_ver = "v143"
+ 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