Skip to content

Commit

Permalink
Merge pull request godotengine#44018 from lyubomirv/mingw_use_static_…
Browse files Browse the repository at this point in the history
…cpp_option

Add 'use_static_cpp' option for MinGW builds
  • Loading branch information
akien-mga authored Dec 3, 2020
2 parents ea7dd1b + e52c9c2 commit 586a208
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions platform/windows/detect.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ def get_opts():
BoolVariable("use_mingw", "Use the Mingw compiler, even if MSVC is installed. Only used on Windows.", False),
BoolVariable("use_llvm", "Use the LLVM compiler", False),
BoolVariable("use_thinlto", "Use ThinLTO", False),
BoolVariable("use_static_cpp", "Link MinGW/MSVC C++ runtime libraries statically", True),
]


Expand Down Expand Up @@ -221,7 +222,11 @@ def configure_msvc(env, manual_msvc_config):

## Compile/link flags

env.AppendUnique(CCFLAGS=["/MT", "/Gd", "/GR", "/nologo"])
if env["use_static_cpp"]:
env.AppendUnique(CCFLAGS=["/MT"])
else:
env.AppendUnique(CCFLAGS=["/MD"])
env.AppendUnique(CCFLAGS=["/Gd", "/GR", "/nologo"])
# Force to use Unicode encoding
env.AppendUnique(CCFLAGS=["/utf-8"])
env.AppendUnique(CXXFLAGS=["/TP"]) # assume all sources are C++
Expand Down Expand Up @@ -373,12 +378,14 @@ def configure_mingw(env):
mingw_prefix = ""

if env["bits"] == "32":
env.Append(LINKFLAGS=["-static"])
env.Append(LINKFLAGS=["-static-libgcc"])
env.Append(LINKFLAGS=["-static-libstdc++"])
if env["use_static_cpp"]:
env.Append(LINKFLAGS=["-static"])
env.Append(LINKFLAGS=["-static-libgcc"])
env.Append(LINKFLAGS=["-static-libstdc++"])
mingw_prefix = env["mingw_prefix_32"]
else:
env.Append(LINKFLAGS=["-static"])
if env["use_static_cpp"]:
env.Append(LINKFLAGS=["-static"])
mingw_prefix = env["mingw_prefix_64"]

if env["use_llvm"]:
Expand Down

0 comments on commit 586a208

Please sign in to comment.