diff options
| author | ruki <[email protected]> | 2021-11-10 00:21:29 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2021-11-10 00:21:29 +0800 |
| commit | 0a17c9c9d9143dfa4281efb13b0f550533d96a18 (patch) | |
| tree | e04530f85f0b3cab8c29ec6daac253fbc8573fdd /xmake/rules/c++ | |
| parent | f0d88dbc6bf6b06724edf942488a8e21050c9484 (diff) | |
support std for c++ modules/msvc
Diffstat (limited to 'xmake/rules/c++')
| -rw-r--r-- | xmake/rules/c++/modules/build_modules/msvc.lua | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/xmake/rules/c++/modules/build_modules/msvc.lua b/xmake/rules/c++/modules/build_modules/msvc.lua index 831b5cd88..8b28d68f6 100644 --- a/xmake/rules/c++/modules/build_modules/msvc.lua +++ b/xmake/rules/c++/modules/build_modules/msvc.lua @@ -37,7 +37,9 @@ function build_with_batchjobs(target, batchjobs, sourcebatch, opt) -- get output flag local cachedir local outputflag + local hasifc = false if compinst:has_flags("/ifcOutput") then + hasifc = true outputflag = "/ifcOutput" cachedir = path.join(target:autogendir(), "rules", "modules", "cache") if not os.isdir(cachedir) then @@ -66,6 +68,15 @@ function build_with_batchjobs(target, batchjobs, sourcebatch, opt) end assert(referenceflag, "compiler(msvc): does not support c++ module!") + -- get stdifcdir flag + local stdifcdirflag + if compinst:has_flags("/stdIfcDir") then + stdifcdirflag = "/stdIfcDir" + elseif compinst:has_flags("/module:stdIfcDir") then + stdifcdirflag = "/module:stdIfcDir" + end + assert(stdifcdirflag, "compiler(msvc): does not support c++ module!") + -- we need patch objectfiles to sourcebatch for linking module objects local modulefiles = {} sourcebatch.sourcekind = "cxx" @@ -116,6 +127,20 @@ function build_with_batchjobs(target, batchjobs, sourcebatch, opt) if cachedir then target:add("cxxflags", "/ifcSearchDir " .. os.args(cachedir)) end + if stdifcdirflag then + 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") + if os.isdir(stdifcdir) then + target:add("cxxflags", stdifcdirflag .. " " .. winos.short_path(stdifcdir)) + end + end + break + end + end + end -- build batchjobs local rootjob = opt.rootjob |
