diff options
| author | Arthur LAURENT <[email protected]> | 2023-08-15 18:17:14 +0200 |
|---|---|---|
| committer | Arthur LAURENT <[email protected]> | 2023-08-15 18:17:14 +0200 |
| commit | b2409c79d337f6160a86cce03ae6013e042ab934 (patch) | |
| tree | 2a02444846b78617fc691b86ac59d80493dd8f81 /xmake/rules/c++/modules/modules_support/msvc.lua | |
| parent | 6061906acf2d05cd207e79c1934b208cfac337df (diff) | |
use /experimental:modules on msvc only when VS version is < to 16.11
Diffstat (limited to 'xmake/rules/c++/modules/modules_support/msvc.lua')
| -rw-r--r-- | xmake/rules/c++/modules/modules_support/msvc.lua | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/xmake/rules/c++/modules/modules_support/msvc.lua b/xmake/rules/c++/modules/modules_support/msvc.lua index 703374423..2822c8949 100644 --- a/xmake/rules/c++/modules/modules_support/msvc.lua +++ b/xmake/rules/c++/modules/modules_support/msvc.lua @@ -133,9 +133,13 @@ end -- load module support for the current target function load(target) - -- add modules flags + -- add modules flags if visual studio version is < 16.11 (vc 14.29) local modulesflag = get_modulesflag(target) - target:add("cxxflags", modulesflag) + local msvc = target:toolchain("msvc") + local vcvars = msvc:config("vcvars") + if vcvars.VCInstallDir and vcvars.VCToolsVersion and semver.compare(vcvars.VCToolsVersion, "14.29") == -1 then + target:add("cxxflags", modulesflag) + end -- enable std modules if c++23 by defaults if target:data("c++.msvc.enable_std_import") == nil then @@ -606,7 +610,11 @@ function get_modulesflag(target) if compinst:has_flags("-experimental:module", "cxxflags", {flagskey = "cl_experimental_module"}) then modulesflag = "-experimental:module" end - assert(modulesflag, "compiler(msvc): does not support c++ module!") + local msvc = target:toolchain("msvc") + local vcvars = msvc:config("vcvars") + if vcvars.VCInstallDir and vcvars.VCToolsVersion and semver.compare(vcvars.VCToolsVersion, "14.29") == -1 then + assert(modulesflag, "compiler(msvc): does not support c++ module!") + end _g.modulesflag = modulesflag or false end return modulesflag or nil |
