diff options
| author | ruki <[email protected]> | 2026-01-17 08:18:03 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2026-01-17 08:18:03 +0800 |
| commit | a2ad47fdedbb14ffe722287312a6444dcc2607e3 (patch) | |
| tree | e090d46640478a472a4927a0b94ab09c8751b65b | |
| parent | 4d9a7aeaaf2732ee846ee452f46370a29b6de038 (diff) | |
| parent | 87da1fada35ab075104a5b7bc855a0ced986ca10 (diff) | |
Merge pull request #7231 from xmake-io/modules
fix get flag in module support
| -rw-r--r-- | xmake/rules/c++/modules/gcc/support.lua | 3 | ||||
| -rw-r--r-- | xmake/rules/c++/modules/msvc/support.lua | 4 |
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 112272893..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) 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 1f066de43..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) 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 |
