diff options
| author | ruki <[email protected]> | 2024-05-30 22:37:24 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2024-05-30 22:37:24 +0800 |
| commit | 6e957e6a5ac524d86d2b300b8c4249c07608c7ce (patch) | |
| tree | 2f07c54cc1c078ab00cfde1a47c978e2ab6b4df8 | |
| parent | 8e54ce3c30e505427c194f35dccd31762ef7ca14 (diff) | |
improve exceptions
| -rw-r--r-- | xmake/plugins/project/cmake/cmakelists.lua | 34 |
1 files changed, 1 insertions, 33 deletions
diff --git a/xmake/plugins/project/cmake/cmakelists.lua b/xmake/plugins/project/cmake/cmakelists.lua index 14f811ce7..805212d53 100644 --- a/xmake/plugins/project/cmake/cmakelists.lua +++ b/xmake/plugins/project/cmake/cmakelists.lua @@ -701,44 +701,12 @@ end -- add target exceptions function _add_target_exceptions(cmakelists, target) - local flags_gcc = - { - cxx = "-fexceptions", - ["no-cxx"] = "-fno-exceptions", - objc = "-fobjc-exceptions", - ["no-objc"] = "-fno-objc-exceptions" - } - local flags_clang = - { - cxx = "-fcxx-exceptions", - ["no-cxx"] = "-fno-cxx-exceptions", - objc = "-fobjc-exceptions", - ["no-objc"] = "-fno-objc-exceptions" - } - local flags_msvc = - { - cxx = "/EHsc", - ["no-cxx"] = "/EHsc-" - } local exceptions = target:get("exceptions") if exceptions then if exceptions == "none" then cmakelists:print("string(REPLACE \"/EHsc\" \"\" CMAKE_CXX_FLAGS \"${CMAKE_CXX_FLAGS}\")") else - cmakelists:print("if(MSVC)") - -- msvc or clang-cl - for _, exception in ipairs(exceptions) do - cmakelists:print(" target_compile_options(%s PRIVATE %s)", target:name(), flags_msvc[exception]) - end - cmakelists:print("elseif(Clang)") - for _, exception in ipairs(exceptions) do - cmakelists:print(" target_compile_options(%s PRIVATE %s)", target:name(), flags_clang[exception]) - end - cmakelists:print("else()") - for _, exception in ipairs(exceptions) do - cmakelists:print(" target_compile_options(%s PRIVATE %s)", target:name(), flags_gcc[exception]) - end - cmakelists:print("endif()") + _add_target_values(cmakelists, target, "exceptions") end end end |
