summaryrefslogtreecommitdiff
path: root/xmake/rules/c++/modules/modules_support/msvc.lua
diff options
context:
space:
mode:
authorArthur LAURENT <[email protected]>2022-12-12 19:49:22 +0100
committerArthur LAURENT <[email protected]>2022-12-12 19:49:22 +0100
commitd0f88a03ac9aa31df054cf3b91b660c1e696dcaa (patch)
treeef4bfb1f0ae9d9f556584a7436b2576c0c4513e7 /xmake/rules/c++/modules/modules_support/msvc.lua
parente4d4e9b9f42eb9443438c632a72add9560e517ac (diff)
fix compilation on c++23 std modules unsupported msvc
Diffstat (limited to 'xmake/rules/c++/modules/modules_support/msvc.lua')
-rw-r--r--xmake/rules/c++/modules/modules_support/msvc.lua10
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