[SCons] Link MSVC debug runtime for optimize=none|debug only.

Select windows runtime in "targets" tool, use "/MDd" flag only when
building with optimize="none" and optimize="debug".
pull/932/head
Fabio Alessandrelli 2022-11-19 18:10:39 +01:00
parent 6c2f9196d7
commit edf02f8319
2 changed files with 7 additions and 7 deletions

View File

@ -55,7 +55,7 @@ def generate(env):
env["optimize"] = ARGUMENTS.get("optimize", opt_level) env["optimize"] = ARGUMENTS.get("optimize", opt_level)
env["debug_symbols"] = get_cmdline_bool("debug_symbols", env.dev_build) env["debug_symbols"] = get_cmdline_bool("debug_symbols", env.dev_build)
if "is_msvc" in env and env["is_msvc"]: if env.get("is_msvc", False):
if env["debug_symbols"]: if env["debug_symbols"]:
env.Append(CCFLAGS=["/Zi", "/FS"]) env.Append(CCFLAGS=["/Zi", "/FS"])
env.Append(LINKFLAGS=["/DEBUG:FULL"]) env.Append(LINKFLAGS=["/DEBUG:FULL"])
@ -66,8 +66,12 @@ def generate(env):
elif env["optimize"] == "size": elif env["optimize"] == "size":
env.Append(CCFLAGS=["/O1"]) env.Append(CCFLAGS=["/O1"])
env.Append(LINKFLAGS=["/OPT:REF"]) env.Append(LINKFLAGS=["/OPT:REF"])
elif env["optimize"] == "debug" or env["optimize"] == "none":
env.Append(CCFLAGS=["/Od"]) if env["optimize"] == "debug" or env["optimize"] == "none":
env.Append(CCFLAGS=["/MDd", "/Od"])
else:
env.Append(CCFLAGS=["/MD"])
else: else:
if env["debug_symbols"]: if env["debug_symbols"]:
if env.dev_build: if env.dev_build:

View File

@ -27,10 +27,6 @@ def generate(env):
env.Append(CPPDEFINES=["TYPED_METHOD_BIND", "NOMINMAX"]) env.Append(CPPDEFINES=["TYPED_METHOD_BIND", "NOMINMAX"])
env.Append(CCFLAGS=["/EHsc"]) env.Append(CCFLAGS=["/EHsc"])
env.Append(LINKFLAGS=["/WX"]) env.Append(LINKFLAGS=["/WX"])
if env["debug_symbols"] or env["target"] == "debug":
env.Append(CCFLAGS=["/MDd"])
else:
env.Append(CCFLAGS=["/MD"])
if env["use_clang_cl"]: if env["use_clang_cl"]:
env["CC"] = "clang-cl" env["CC"] = "clang-cl"