summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2026-01-17 00:46:08 +0800
committerruki <[email protected]>2026-01-17 00:46:08 +0800
commit87da1fada35ab075104a5b7bc855a0ced986ca10 (patch)
treee090d46640478a472a4927a0b94ab09c8751b65b
parentd2da2792f328eca7cd527f2f878fa91fac307ee3 (diff)
fix get flag again
-rw-r--r--xmake/rules/c++/modules/gcc/support.lua3
-rw-r--r--xmake/rules/c++/modules/msvc/support.lua4
2 files changed, 5 insertions, 2 deletions
diff --git a/xmake/rules/c++/modules/gcc/support.lua b/xmake/rules/c++/modules/gcc/support.lua
index e4e598107..623444ce4 100644
--- a/xmake/rules/c++/modules/gcc/support.lua
+++ b/xmake/rules/c++/modules/gcc/support.lua
@@ -311,7 +311,8 @@ function get_cppversionflag(target)
if cppversionflag == nil then
local compinst = target:compiler("cxx")
local flags = compinst:compflags({target = target})
- cppversionflag = table.find_if(flags, function(v) return string.startswith(v, "-std=c++") end) or "-std=c++20"
+ local idx = table.find_first_if(flags, function(_, v) return string.startswith(v, "-std=c++") end)
+ cppversionflag = (idx and flags[idx]) or "-std=c++20"
_g.cppversionflag = cppversionflag
end
return cppversionflag or nil
diff --git a/xmake/rules/c++/modules/msvc/support.lua b/xmake/rules/c++/modules/msvc/support.lua
index 98e6a56c9..588921d0e 100644
--- a/xmake/rules/c++/modules/msvc/support.lua
+++ b/xmake/rules/c++/modules/msvc/support.lua
@@ -261,7 +261,9 @@ function get_cppversionflag(target)
if cppversionflag == nil then
local compinst = target:compiler("cxx")
local flags = compinst:compflags({target = target})
- cppversionflag = table.find_if(flags, function(v) return string.startswith(v, "/std:c++") end) or "/std:c++latest"
+ local idx = table.find_first_if(flags, function(_, v) return string.startswith(v, "/std:c++") end)
+ cppversionflag = (idx and flags[idx]) or "/std:c++latest"
+ _g.cppversionflag = cppversionflag
end
return cppversionflag or nil
end