diff options
| author | ruki <[email protected]> | 2023-01-06 09:24:30 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2023-01-06 09:24:30 +0800 |
| commit | 964c5096ff9d4fdfd96417eeb3704f3117b26503 (patch) | |
| tree | 8b74d554dfab87f07e6f3223a3644a09b010e6c7 | |
| parent | aca51a2079ecdb010085d954c04b5aa5b11d3ed1 (diff) | |
| parent | 1938de01114d01584b8a6e24b8e7c7980a9250eb (diff) | |
Merge pull request #3247 from Arthapz/qt-cpplanguage-overwrite
conditionnaly add c++17 flag on qt rules
| -rw-r--r-- | xmake/rules/qt/load.lua | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/xmake/rules/qt/load.lua b/xmake/rules/qt/load.lua index 0d6ea17f8..022b37d5b 100644 --- a/xmake/rules/qt/load.lua +++ b/xmake/rules/qt/load.lua @@ -102,6 +102,17 @@ function _add_includedirs(target, includedirs) end end +-- get target c++ version +function _get_target_cppversion(target) + local languages = target:get("languages") + for _, language in ipairs(languages) do + if language:startswith("c++") or language:startswith("cxx") then + local v = language:match("%d+") or language:match("latest") + if v then return v end + end + end +end + -- the main entry function main(target, opt) @@ -138,15 +149,22 @@ function main(target, opt) if not cxxlang then -- Qt6 require at least '/std:c++17' -- @see https://github.com/xmake-io/xmake/issues/1183 + local cppversion = _get_target_cppversion(target) if qt_sdkver:ge("6.0") then - target:add("languages", "c++17") + -- add conditionnaly c++17 to avoid for example "cl : Command line warning D9025 : overriding '/std:c++latest' with '/std:c++17'" warning + if (not cppversion) or (cppversion ~= "latest") or (tonumber(cppversion) and tonumber(cppversion) < 17) then + target:add("languages", "c++17") + end -- @see https://github.com/xmake-io/xmake/issues/2071 if target:is_plat("windows") then target:add("cxxflags", "/Zc:__cplusplus") target:add("cxxflags", "/permissive-") end else - target:add("languages", "c++11") + -- add conditionnaly c++11 to avoid for example "cl : Command line warning D9025 : overriding '/std:c++latest' with '/std:c++11'" warning + if (not cppversion) or (cppversion ~= "latest") or (tonumber(cppversion) and tonumber(cppversion) < 11) then + target:add("languages", "c++11") + end end end |
