summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArthur LAURENT <[email protected]>2023-01-05 17:04:40 +0100
committerArthur LAURENT <[email protected]>2023-01-05 17:05:14 +0100
commit598428d35d8f259a87102d1fe17027a503633652 (patch)
tree9a6726e925a734e816bce8f7f98972283c0f6c65
parent93935417a2c56c3ddc9ea715939441fe41f792f2 (diff)
conditionnaly add c++17 flag on qt rules
-rw-r--r--xmake/rules/qt/load.lua21
1 files changed, 20 insertions, 1 deletions
diff --git a/xmake/rules/qt/load.lua b/xmake/rules/qt/load.lua
index 0d6ea17f8..32be0bd61 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,14 +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 (not 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
+ -- 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 (not cppversion == "latest") or (tonumber(cppversion) and tonumber(cppversion) < 11) then
+ target:add("languages", "c++17")
+ end
target:add("languages", "c++11")
end
end