From 03766e4cf5df0cedd9f18f72b089dfac61a82821 Mon Sep 17 00:00:00 2001 From: ruki Date: Wed, 14 Sep 2022 00:44:30 +0800 Subject: improve optimize for cl --- xmake/modules/core/tools/cl.lua | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/xmake/modules/core/tools/cl.lua b/xmake/modules/core/tools/cl.lua index 506f9e6d7..177b97669 100644 --- a/xmake/modules/core/tools/cl.lua +++ b/xmake/modules/core/tools/cl.lua @@ -158,15 +158,19 @@ end -- make the optimize flag function nf_optimize(self, level) - local maps = - { - none = "-Od" - , faster = "-O2" - , fastest = "-Ox -fp:fast" - , smallest = "-O1 -GL" -- /GL and (/OPT:REF is on by default in linker), we need enable /ltcg - , aggressive = "-Ox -fp:fast" - } - return maps[level] + -- only for source kind + local kind = self:kind() + if language.sourcekinds()[kind] then + local maps = + { + none = "-Od" + , faster = "-Ox" + , fastest = "-O2 -fp:fast" + , smallest = "-O1 -GL" -- /GL and (/OPT:REF is on by default in linker), we need enable /ltcg + , aggressive = "-O2 -fp:fast" + } + return maps[level] + end end -- make vs runtime flag -- cgit v1.3.1