summaryrefslogtreecommitdiff
path: root/xmake/rules/c++/modules/modules_support/msvc
diff options
context:
space:
mode:
authorArthur LAURENT <[email protected]>2024-01-23 20:05:00 +0100
committerArthur LAURENT <[email protected]>2024-01-26 18:20:58 +0100
commita6f1cc3b301da925684e937489bddf8c41ac440a (patch)
tree15ebdd564192a7aa0acaf51fc778491aab243f7c /xmake/rules/c++/modules/modules_support/msvc
parent7dddd80a592a16f5b718ec8cf96254ac220205f7 (diff)
add a policy to toggle C++23 std module
Diffstat (limited to 'xmake/rules/c++/modules/modules_support/msvc')
-rw-r--r--xmake/rules/c++/modules/modules_support/msvc/compiler_support.lua26
1 files changed, 15 insertions, 11 deletions
diff --git a/xmake/rules/c++/modules/modules_support/msvc/compiler_support.lua b/xmake/rules/c++/modules/modules_support/msvc/compiler_support.lua
index 3b6aafb9a..3f67e0291 100644
--- a/xmake/rules/c++/modules/modules_support/msvc/compiler_support.lua
+++ b/xmake/rules/c++/modules/modules_support/msvc/compiler_support.lua
@@ -31,7 +31,7 @@ function load(target)
local vcvars = msvc:config("vcvars")
-- enable std modules if c++23 by defaults
- if target:data("c++.msvc.enable_std_import") == nil then
+ if target:data("c++.msvc.enable_std_import") == nil and target:policy("build.c++.modules.std") then
local languages = target:get("languages")
local isatleastcpp23 = false
for _, language in ipairs(languages) do
@@ -70,22 +70,26 @@ function toolchain_includedirs(target)
raise("msvc toolchain includedirs not found!")
end
+-- build c++23 standard modules if needed
function get_stdmodules(target)
- -- build c++23 standard modules if needed
- if target:data("c++.msvc.enable_std_import") then
- local msvc = target:toolchain("msvc")
- if msvc then
- local vcvars = msvc:config("vcvars")
- if vcvars.VCInstallDir and vcvars.VCToolsVersion then
- modules = {}
+ if target:policy("build.c++.modules.std") then
+ if target:data("c++.msvc.enable_std_import") then
+ local msvc = target:toolchain("msvc")
+ if msvc then
+ local vcvars = msvc:config("vcvars")
+ if vcvars.VCInstallDir and vcvars.VCToolsVersion then
+ modules = {}
- local stdmodulesdir = path.join(vcvars.VCInstallDir, "Tools", "MSVC", vcvars.VCToolsVersion, "modules")
- assert(stdmodulesdir, "Can't enable C++23 std modules, directory missing !")
+ local stdmodulesdir = path.join(vcvars.VCInstallDir, "Tools", "MSVC", vcvars.VCToolsVersion, "modules")
+ assert(stdmodulesdir, "Can't enable C++23 std modules, directory missing !")
- return {path.join(stdmodulesdir, "std.ixx"), path.join(stdmodulesdir, "std.compat.ixx")}
+ return {path.join(stdmodulesdir, "std.ixx"), path.join(stdmodulesdir, "std.compat.ixx")}
+ end
end
end
end
+
+ return {}
end
function get_bmi_extension()