summaryrefslogtreecommitdiff
path: root/xmake/rules/c++/modules/modules_support/msvc.lua
diff options
context:
space:
mode:
authorruki <[email protected]>2022-11-05 00:38:31 +0800
committerruki <[email protected]>2022-11-05 00:38:31 +0800
commit181a337b4092af6691d8e2e135d21dae4a03556a (patch)
treef5c3948d20cacb3bfe6225dee8c35970890b9245 /xmake/rules/c++/modules/modules_support/msvc.lua
parentb9c18ddfd99ca4d2bb3d5dec76a8bc1b24394bf2 (diff)
improve std modules for msvc
Diffstat (limited to 'xmake/rules/c++/modules/modules_support/msvc.lua')
-rw-r--r--xmake/rules/c++/modules/modules_support/msvc.lua25
1 files changed, 15 insertions, 10 deletions
diff --git a/xmake/rules/c++/modules/modules_support/msvc.lua b/xmake/rules/c++/modules/modules_support/msvc.lua
index 04ab2bf7a..b57ac4520 100644
--- a/xmake/rules/c++/modules/modules_support/msvc.lua
+++ b/xmake/rules/c++/modules/modules_support/msvc.lua
@@ -126,25 +126,30 @@ end
-- load module support for the current target
function load(target)
- -- get flags
- local modulesflag = get_modulesflag(target)
-- add modules flags
+ local modulesflag = get_modulesflag(target)
target:add("cxxflags", modulesflag)
-- add stdifcdir in case of if the user ask for it
- if target:values("msvc.modules.stdifcdir") then
- local stdifcdirflag = get_stdifcdirflag(target)
- for _, toolchain_inst in ipairs(target:toolchains()) do
- if toolchain_inst:name() == "msvc" then
- local vcvars = toolchain_inst:config("vcvars")
- if vcvars.VCInstallDir and vcvars.VCToolsVersion then
- local stdifcdir = path.join(vcvars.VCInstallDir, "Tools", "MSVC", vcvars.VCToolsVersion, "ifc", target:is_arch("x64") and "x64" or "x86")
+ local stdifcdirflag = get_stdifcdirflag(target)
+ if stdifcdirflag then
+ local msvc = target:toolchain("msvc")
+ if msvc then
+ local vcvars = msvc:config("vcvars")
+ if vcvars.VCInstallDir and vcvars.VCToolsVersion then
+ local arch
+ if target:is_arch("x64", "x86_64") then
+ arch = "x64"
+ elseif target:is_arch("x86", "i386") then
+ arch = "x86"
+ end
+ if arch then
+ local stdifcdir = path.join(vcvars.VCInstallDir, "Tools", "MSVC", vcvars.VCToolsVersion, "ifc", arch)
if os.isdir(stdifcdir) then
target:add("cxxflags", {stdifcdirflag, winos.short_path(stdifcdir)}, {force = true, expand = false})
end
end
- break
end
end
end