diff options
| author | ruki <[email protected]> | 2019-05-21 18:56:46 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2019-05-21 18:56:46 +0800 |
| commit | b543bb4cb820298246d79277722d8ecd94ee3a17 (patch) | |
| tree | b2fcc7213cbcfad5f1dee65bed497e5bb43be8e1 | |
| parent | e0dd88cfd0f55f656fe865da208bc629bf78faa5 (diff) | |
| parent | 82277e5222154ff4463127681f2d18abb07d7f4a (diff) | |
Merge pull request #421 from OpportunityLiu/nvcc-warnings
修复Nvcc warnings对host compiler的支持
| -rw-r--r-- | xmake/modules/core/tools/nvcc.lua | 61 |
1 files changed, 45 insertions, 16 deletions
diff --git a/xmake/modules/core/tools/nvcc.lua b/xmake/modules/core/tools/nvcc.lua index 543d5d5a4..b830e2c65 100644 --- a/xmake/modules/core/tools/nvcc.lua +++ b/xmake/modules/core/tools/nvcc.lua @@ -40,9 +40,9 @@ function init(self) self:set("mapflags", { -- warnings - ["-W1"] = "-Wall" - , ["-W2"] = "-Wall" - , ["-W3"] = "-Wall" + ["-W4"] = "-Wreorder" + , ["-Wextra"] = "-Wreorder" + , ["-Weverything"] = "-Wreorder" }) -- init buildmodes @@ -72,27 +72,56 @@ function nf_warning(self, level) local maps = { none = "-w" + , less = nil + , more = nil + , all = nil , extra = "-Wreorder" , everything = "-Wreorder" , error = "-Werror" } + + -- for cl.exe on windows + local cl_maps = + { + none = "-W0" + , less = "-W1" + , more = "-W3" + , all = "-W3" -- = "-Wall" will enable too more warnings + , extra = "-W4" + , everything = "-Wall" + , error = "-WX" + } + -- for gcc & clang on linux, may be work for other gnu compatible compilers such as icc + local gcc_clang_maps = + { + none = "-w" + , less = "-Wall" + , more = "-Wall" + , all = "-Wall" + , extra = "-Wextra" + -- gcc dosen't support `-Weverything`, use `-Wall -Wextra -Weffc++` for it + -- no warning will emit for unsupoorted `-W` flags by clang/gcc + , everything = "-Weverything -Wall -Wextra -Weffc++" + , error = "-Werror" + } + local warning = maps[level] - if not warning then - -- for cl.exe - if is_plat("windows") then - maps.less = "-Xcompiler -W1" - maps.more = "-Xcompiler -W3" - maps.all = "-Xcompiler -W3" - -- for gcc/clang - elseif self:has_flags("-Xcompiler -Wall", "cxflags") then - maps.less = "-Xcompiler -Wall" - maps.more = "-Xcompiler -Wall" - maps.all = "-Xcompiler -Wall" - end - warning = maps[level] + + local host_warning = nil + -- for cl.exe on windows, it is the only supported host compiler on the platform + if is_plat("windows") then + host_warning = cl_maps[level] + -- for gcc/clang, or any gnu compatible compiler on *nix + else + host_warning = gcc_clang_maps[level] + end + + if host_warning then + warning = ((warning or "") .. ' -Xcompiler "' .. host_warning .. '"'):trim() end return warning + end -- make the optimize flag |
