From fce2659ef7e3be32a19d474ea254c9407880cdbe Mon Sep 17 00:00:00 2001 From: ruki Date: Wed, 22 Mar 2023 23:34:16 +0800 Subject: add vs runtime for clang #3546 --- xmake/modules/core/tools/clang.lua | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/xmake/modules/core/tools/clang.lua b/xmake/modules/core/tools/clang.lua index 521f31361..16bc0f245 100644 --- a/xmake/modules/core/tools/clang.lua +++ b/xmake/modules/core/tools/clang.lua @@ -164,3 +164,26 @@ function nf_exception(self, exp) end end +-- make vs runtime flag +-- @see https://github.com/xmake-io/xmake/issues/3546 +function nf_runtime(self, vs_runtime) + if self:is_plat("windows") and vs_runtime then + local maps + local kind = self:kind() + if language.sourcekinds()[kind] then + maps = { + MT = "-fms-runtime-lib=static", + MTd = "-fms-runtime-lib=static_dbg", + MD = "-fms-runtime-lib=dll", + MDd = "-fms-runtime-lib=dll_dbg" + } + elseif kind == "ld" or kind == "sh" then + maps = { + MD = "-lmsvcrt", + MDd = "-lmsvcrtd" + } + end + return maps and maps[vs_runtime] + end +end + -- cgit v1.3.1