Align MSVC runtime (MD[d], MT) options to engine #1647

Engine has an option to link to MDd debug_crt
add flag to SCons options
Add flag to CMAKE options
This commit is contained in:
Samuel Nicholas
2024-11-28 08:55:00 +10:30
parent a42b3634d2
commit b7dbd26d8f
2 changed files with 13 additions and 13 deletions

View File

@@ -78,6 +78,7 @@ def options(opts):
opts.Add(BoolVariable("use_mingw", "Use the MinGW compiler instead of MSVC - only effective on Windows", False))
opts.Add(BoolVariable("use_static_cpp", "Link MinGW/MSVC C++ runtime libraries statically", True))
opts.Add(BoolVariable("silence_msvc", "Silence MSVC's cl/link stdout bloat, redirecting errors to stderr.", True))
opts.Add(BoolVariable("debug_crt", "Compile with MSVC's debug CRT (/MDd)", False))
opts.Add(BoolVariable("use_llvm", "Use the LLVM compiler (MVSC or MinGW depending on the use_mingw flag)", False))
opts.Add("mingw_prefix", "MinGW prefix", mingw)
@@ -117,10 +118,14 @@ def generate(env):
env["CC"] = "clang-cl"
env["CXX"] = "clang-cl"
if env["use_static_cpp"]:
env.Append(CCFLAGS=["/MT"])
if env["debug_crt"]:
# Always use dynamic runtime, static debug CRT breaks thread_local.
env.AppendUnique(CCFLAGS=["/MDd"])
else:
env.Append(CCFLAGS=["/MD"])
if env["use_static_cpp"]:
env.AppendUnique(CCFLAGS=["/MT"])
else:
env.AppendUnique(CCFLAGS=["/MD"])
if env["silence_msvc"] and not env.GetOption("clean"):
silence_msvc(env)