diff options
| author | ruki <[email protected]> | 2022-11-04 22:44:52 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2022-11-04 22:44:52 +0800 |
| commit | 6c819d681111add7afa70920b788d8d56f620d77 (patch) | |
| tree | 9a7f2af95e6e16541fd05dc7dec3957f79df69b3 /xmake/rules/c++/modules/modules_support/msvc.lua | |
| parent | 9fe1d17945bc670c0ec3b394c39e17e0cedb7b44 (diff) | |
| parent | 0fdefd2f7280db640ed09df068e09f98649ce7ec (diff) | |
Merge pull request #3016 from xmake-io/module
Improve clang/gcc/msvc to better support std modules
Diffstat (limited to 'xmake/rules/c++/modules/modules_support/msvc.lua')
| -rw-r--r-- | xmake/rules/c++/modules/modules_support/msvc.lua | 25 |
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 |
