summaryrefslogtreecommitdiff
path: root/xmake/rules/c++/modules/modules_support/gcc.lua
diff options
context:
space:
mode:
authorArthur LAURENT <[email protected]>2022-11-30 23:34:45 +0100
committerArthur LAURENT <[email protected]>2022-11-30 23:34:45 +0100
commit97c36a86e182c2fcac292275badf2cd231eb8640 (patch)
tree17109ef162f0621ceb2a54454684f48c3cad3726 /xmake/rules/c++/modules/modules_support/gcc.lua
parent7735eb5da1f03fa0fc3152cfc4901daf3cad9845 (diff)
Add defines to clang and gcc
Diffstat (limited to 'xmake/rules/c++/modules/modules_support/gcc.lua')
-rw-r--r--xmake/rules/c++/modules/modules_support/gcc.lua17
1 files changed, 16 insertions, 1 deletions
diff --git a/xmake/rules/c++/modules/modules_support/gcc.lua b/xmake/rules/c++/modules/modules_support/gcc.lua
index 1d26a543e..3d427c1d2 100644
--- a/xmake/rules/c++/modules/modules_support/gcc.lua
+++ b/xmake/rules/c++/modules/modules_support/gcc.lua
@@ -146,8 +146,13 @@ function generate_dependencies(target, sourcebatch, opt)
os.vrunv(compinst:program(), table.join(compinst:compflags({target = target}), common_args, args), {envs = vcvars})
else
common.fallback_generate_dependencies(target, jsonfile, sourcefile, function(file)
+ local compinst = target:compiler("cxx")
+ local defines = {}
+ for _, define in ipairs(target:get("defines")) do
+ table.insert(defines, "-D" .. define)
+ end
local ifile = path.translate(path.join(outputdir, path.filename(file) .. ".i"))
- os.vrunv(compinst:program(), {"-E", "-x", "c++", file, "-o", ifile})
+ os.vrunv(compinst:program(), table.join(defines, {get_cppversionflag(target), "-E", "-x", "c++", file, "-o", ifile}))
return io.readfile(ifile)
end)
end
@@ -477,3 +482,13 @@ function get_depoutputflag(target)
end
return depoutputflag or nil
end
+
+function get_cppversionflag(target)
+ local cppversionflag = _g.cppversionflag
+ if cppversionflag == nil then
+ local compinst = target:compiler("cxx")
+ local flags = compinst:compflags({target = target})
+ cppversionflag = table.find_if(flags, function(v) string.startswith(v, "-std=c++") end) or "-std=c++20"
+ end
+ return cppversionflag or nil
+end \ No newline at end of file