From 103421e89a343979122fef36f3c81943b4d02f31 Mon Sep 17 00:00:00 2001 From: Lynix Date: Tue, 19 Jul 2022 20:03:33 +0200 Subject: [PATCH] Fix xmake for msys2 --- xmake.lua | 5 +---- xmake/rules/msys2_isystem_fix.lua | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 4 deletions(-) create mode 100644 xmake/rules/msys2_isystem_fix.lua diff --git a/xmake.lua b/xmake.lua index 5b27e3e72..e452306e0 100644 --- a/xmake.lua +++ b/xmake.lua @@ -210,10 +210,7 @@ elseif is_plat("mingw") then add_ldflags("-Wa,-mbig-obj") if is_subhost("msys", "cygwin") then - -- disable -isystem for packages as it's broken on msys2 (see https://github.com/msys2/MINGW-packages/issues/10761) - if project.policy("package.include_external_headers") == nil then - set_policy("package.include_external_headers", false) - end + add_rules("msys2.isystem.fix") end end diff --git a/xmake/rules/msys2_isystem_fix.lua b/xmake/rules/msys2_isystem_fix.lua new file mode 100644 index 000000000..cb07521a3 --- /dev/null +++ b/xmake/rules/msys2_isystem_fix.lua @@ -0,0 +1,14 @@ +rule("msys2.isystem.fix") + on_load(function (target) + import("core.project.project") + + local external = project.policy("package.include_external_headers") + if external == nil then + external = target:policy("package.include_external_headers") + end + + -- disable -isystem for packages as it seems broken on msys2 (see https://github.com/msys2/MINGW-packages/issues/10761) + if external == nil then + target:set("policy", "package.include_external_headers", false) + end + end)