diff options
| author | ruki <[email protected]> | 2024-03-22 22:58:59 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2024-03-22 22:58:59 +0800 |
| commit | fe6ad08f154298b105f82464f8d1c2d5a35241cc (patch) | |
| tree | a38f887b3d190abac9c8f9da6a3407a920621f94 | |
| parent | 24859ec6ddb1e11a8eaee0c5e79293a67161a4e7 (diff) | |
fix cmake generator #4865
| -rw-r--r-- | xmake/plugins/project/cmake/cmakelists.lua | 37 |
1 files changed, 23 insertions, 14 deletions
diff --git a/xmake/plugins/project/cmake/cmakelists.lua b/xmake/plugins/project/cmake/cmakelists.lua index 0db9ccaca..9670972c9 100644 --- a/xmake/plugins/project/cmake/cmakelists.lua +++ b/xmake/plugins/project/cmake/cmakelists.lua @@ -645,31 +645,40 @@ end function _add_target_warnings(cmakelists, target) local flags_gcc = { - none = "-w" - , less = "-Wall" - , more = "-Wall" - , all = "-Wall" - , allextra = "-Wall -Wextra" - , error = "-Werror" + none = "-w" + , less = "-Wall" + , more = "-Wall" + , all = "-Wall" + , allextra = "-Wall -Wextra" + , pedantic = "-Wpedantic" + , everything = "-Wall -Wextra" + , error = "-Werror" } local flags_msvc = { - none = "-W0" - , less = "-W1" - , more = "-W3" - , all = "-W3" -- = "-Wall" will enable too more warnings - , allextra = "-W4" - , error = "-WX" + none = "-W0" + , less = "-W1" + , more = "-W3" + , all = "-W3" -- = "-Wall" will enable too more warnings + , allextra = "-W4" + , everything = "-Wall" + , error = "-WX" } local warnings = target:get("warnings") if warnings then cmakelists:print("if(MSVC)") for _, warn in ipairs(warnings) do - cmakelists:print(" target_compile_options(%s PRIVATE %s)", target:name(), flags_msvc[warn]) + local flag = flags_msvc[warn] + if flag then + cmakelists:print(" target_compile_options(%s PRIVATE %s)", target:name(), flag) + end end cmakelists:print("else()") for _, warn in ipairs(warnings) do - cmakelists:print(" target_compile_options(%s PRIVATE %s)", target:name(), flags_gcc[warn]) + local flag = flags_gcc[warn] + if flag then + cmakelists:print(" target_compile_options(%s PRIVATE %s)", target:name(), flag) + end end cmakelists:print("endif()") end |
