summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2020-12-24 22:43:50 +0800
committerruki <[email protected]>2020-12-24 22:43:50 +0800
commit381e3c74967cfab1c5d42e9ee7fcb68a5a1533f7 (patch)
treee4dea36c784e2fe835587bffd33e69dd12a2cd71
parentaaa7d03b06906cb3be220e8b2817ff795569350b (diff)
add vsruntime config
-rw-r--r--xmake/core/package/package.lua10
-rw-r--r--xmake/platforms/windows/xmake.lua2
2 files changed, 10 insertions, 2 deletions
diff --git a/xmake/core/package/package.lua b/xmake/core/package/package.lua
index 112dca95c..6aaeb2f08 100644
--- a/xmake/core/package/package.lua
+++ b/xmake/core/package/package.lua
@@ -1098,8 +1098,14 @@ function _instance:_generate_build_configs(configs)
if self:is_plat("windows") then
local ld = self:build_getenv("ld")
local vs_runtime = self:config("vs_runtime")
- if ld and path.basename(ld:lower()) == "link" and vs_runtime and vs_runtime == "MT" then
- configs.ldflags = "-nodefaultlib:msvcrt.lib"
+ if vs_runtime and ld and path.basename(ld:lower()) == "link" then -- for msvc?
+ local vs_runtime_cxflags = "/" .. vs_runtime .. (self:debug() and "d" or "")
+ configs.cxflags = table.wrap(configs.cxflags)
+ table.insert(configs.cxflags, vs_runtime_cxflags)
+ if vs_runtime == "MT" then
+ configs.ldflags = table.wrap(configs.ldflags)
+ table.insert(configs.ldflags, "-nodefaultlib:msvcrt.lib")
+ end
end
end
return configs
diff --git a/xmake/platforms/windows/xmake.lua b/xmake/platforms/windows/xmake.lua
index 0c0f88912..2cdc04f21 100644
--- a/xmake/platforms/windows/xmake.lua
+++ b/xmake/platforms/windows/xmake.lua
@@ -51,6 +51,8 @@ platform("windows")
, " e.g. --vs_toolset=14.0" }
, {nil, "vs_sdkver", "kv", nil, "The Windows SDK Version of Visual Studio"
, " e.g. --vs_sdkver=10.0.15063.0" }
+ , {nil, "vs_runtime", "kv", nil, "The Runtime library of Visual Studio",
+ , values = {"MT", "MD"} }
, {category = "Cuda SDK Configuration" }
, {nil, "cuda", "kv", "auto", "The Cuda SDK Directory" }
, {category = "Qt SDK Configuration" }