summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--xmake/rules/qt/load.lua22
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