summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2023-07-07 22:50:33 +0800
committerruki <[email protected]>2023-07-07 22:50:33 +0800
commit6169e9b753f85f238b0a09786c1b84ac1701f547 (patch)
tree70129fe9b58b9b90cbe4914c1dfabbe5adea20c7
parentc801c64e8d272c61e5ee9967a87490ec9f51cfae (diff)
improve moc #3930
-rw-r--r--xmake/rules/qt/moc/xmake.lua14
1 files changed, 12 insertions, 2 deletions
diff --git a/xmake/rules/qt/moc/xmake.lua b/xmake/rules/qt/moc/xmake.lua
index ab2026d20..547c72b3b 100644
--- a/xmake/rules/qt/moc/xmake.lua
+++ b/xmake/rules/qt/moc/xmake.lua
@@ -58,16 +58,26 @@ rule("qt.moc")
-- add commands
batchcmds:show_progress(opt.progress, "${color.build.object}compiling.qt.moc %s", sourcefile)
+ -- get values from target
+ -- @see https://github.com/xmake-io/xmake/issues/3930
+ local function _get_values_from_target(target, name)
+ local values = table.wrap(target:get(name))
+ table.join2(values, target:get_from_opts(name))
+ table.join2(values, target:get_from_pkgs(name))
+ table.join2(values, target:get_from_deps(name, {interface = true}))
+ return table.unique(values)
+ end
+
-- generate c++ source file for moc
local flags = {}
- table.join2(flags, compiler.map_flags("cxx", "define", target:get("defines")))
+ table.join2(flags, compiler.map_flags("cxx", "define", _get_values_from_target(target, "defines")))
local pathmaps = {
{"includedirs", "includedir"},
{"sysincludedirs", "includedir"}, -- for now, moc process doesn't support MSVC external includes flags and will fail
{"frameworkdirs", "frameworkdir"}
}
for _, pathmap in ipairs(pathmaps) do
- for _, item in ipairs(target:get(pathmap[1])) do
+ for _, item in ipairs(_get_values_from_target(target, pathmap[1])) do
local pathitem = path(item, function (p)
local item = table.unwrap(compiler.map_flags("cxx", pathmap[2], p))
if item then