From d0f88a03ac9aa31df054cf3b91b660c1e696dcaa Mon Sep 17 00:00:00 2001 From: Arthur LAURENT Date: Mon, 12 Dec 2022 19:49:22 +0100 Subject: fix compilation on c++23 std modules unsupported msvc --- xmake/rules/c++/modules/modules_support/msvc.lua | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) 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 -- cgit v1.3.1