summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--xmake/rules/lex_yacc/yacc/xmake.lua8
1 files changed, 6 insertions, 2 deletions
diff --git a/xmake/rules/lex_yacc/yacc/xmake.lua b/xmake/rules/lex_yacc/yacc/xmake.lua
index 96da386b3..501bd2b00 100644
--- a/xmake/rules/lex_yacc/yacc/xmake.lua
+++ b/xmake/rules/lex_yacc/yacc/xmake.lua
@@ -23,8 +23,12 @@ rule("yacc")
add_deps("c++")
set_extensions(".y", ".yy")
on_load(function (target)
- local sourcefile_dir = path.join(target:autogendir(), "rules", "yacc_yacc")
- target:add("includedirs", sourcefile_dir)
+ -- add yacc includedirs if there are yacc files
+ -- @see https://github.com/xmake-io/xmake/issues/4820
+ if target:sourcebatches()["yacc"] then
+ local sourcefile_dir = path.join(target:autogendir(), "rules", "yacc_yacc")
+ target:add("includedirs", sourcefile_dir)
+ end
end)
before_buildcmd_file(function (target, batchcmds, sourcefile_yacc, opt)