diff options
| -rw-r--r-- | xmake/rules/c++/modules/modules_support/msvc.lua | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/xmake/rules/c++/modules/modules_support/msvc.lua b/xmake/rules/c++/modules/modules_support/msvc.lua index 198447e43..bd645c694 100644 --- a/xmake/rules/c++/modules/modules_support/msvc.lua +++ b/xmake/rules/c++/modules/modules_support/msvc.lua @@ -132,7 +132,15 @@ function load(target) local languages = table.join({}, target:get("languages")) local disable_on = { "c++11", "cxx11", "c++14", "cxx14", "c++17", "cxx17", "c++20", "cxx20"} local iscpp23 = table.find_if(languages, function(_, v) for _, flag in pairs(disable_on) do if v:find(flag) then return false end end return true end) - target:set("values", "c++.msvc.enable_std_import", iscpp23) + local stdmodulesdir + local msvc = target:toolchain("msvc") + if msvc then + local vcvars = msvc:config("vcvars") + if vcvars.VCInstallDir and vcvars.VCToolsVersion then + stdmodulesdir = path.join(vcvars.VCInstallDir, "Tools", "MSVC", vcvars.VCToolsVersion, "modules") + end + end + target:set("values", "c++.msvc.enable_std_import", iscpp23 and os.isdir(stdmodulesdir)) end -- add stdifcdir in case of if the user ask for it |
