summaryrefslogtreecommitdiff
path: root/xmake/rules/c++/xmake.lua
diff options
context:
space:
mode:
authorruki <[email protected]>2024-09-16 22:41:32 +0800
committerruki <[email protected]>2024-09-16 22:41:32 +0800
commitbe182710a90a20276ac7f2ff76547ddf8e63254e (patch)
tree15f64da10c2746bd7ffd9352ee011f86a4639317 /xmake/rules/c++/xmake.lua
parent95db53c2338b030d0dd99620d388882a3faeb653 (diff)
switch to MT runtime
Diffstat (limited to 'xmake/rules/c++/xmake.lua')
-rw-r--r--xmake/rules/c++/xmake.lua13
1 files changed, 12 insertions, 1 deletions
diff --git a/xmake/rules/c++/xmake.lua b/xmake/rules/c++/xmake.lua
index 49e1963a9..432d37855 100644
--- a/xmake/rules/c++/xmake.lua
+++ b/xmake/rules/c++/xmake.lua
@@ -35,10 +35,21 @@ rule("c++.build")
add_deps("c++.build.pcheader", "c++.build.modules", "c++.build.optimization", "c++.build.sanitizer")
on_build_files("private.action.build.object", {batch = true, distcc = true})
on_config(function (target)
- -- we enable c++ exceptions by default
+ -- enable c++ exceptions by default
if target:is_plat("windows") and not target:get("exceptions") then
target:set("exceptions", "cxx")
end
+ -- enable vs runtime as MD by default
+ if target:is_plat("windows") and not target:get("runtimes") then
+ local vs_runtime_default = target:policy("build.c++.msvc.runtime")
+ if vs_runtime_default and vs_runtime_default == "MD" and target:has_tool("cxx", "cl", "clang_cl") then
+ if is_mode("debug") then
+ target:set("runtimes", "MDd")
+ else
+ target:set("runtimes", "MD")
+ end
+ end
+ end
-- https://github.com/xmake-io/xmake/issues/4621
if target:is_plat("windows") and target:is_static() and target:has_tool("cxx", "tcc") then
target:set("extension", ".a")