Add 'use_static_cpp' option for MinGW and MSVC builds
(cherry picked from commit e52c9c26fc
)
This commit is contained in:
parent
1663a9e87c
commit
d6a65fb13a
|
@ -70,6 +70,7 @@ def get_opts():
|
||||||
BoolVariable("use_mingw", "Use the Mingw compiler, even if MSVC is installed. Only used on Windows.", False),
|
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_llvm", "Use the LLVM compiler", False),
|
||||||
BoolVariable("use_thinlto", "Use ThinLTO", False),
|
BoolVariable("use_thinlto", "Use ThinLTO", False),
|
||||||
|
BoolVariable("use_static_cpp", "Link MinGW/MSVC C++ runtime libraries statically", True),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
@ -208,7 +209,11 @@ def configure_msvc(env, manual_msvc_config):
|
||||||
|
|
||||||
## Compile/link flags
|
## 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
|
# Force to use Unicode encoding
|
||||||
env.AppendUnique(CCFLAGS=["/utf-8"])
|
env.AppendUnique(CCFLAGS=["/utf-8"])
|
||||||
env.AppendUnique(CXXFLAGS=["/TP"]) # assume all sources are C++
|
env.AppendUnique(CXXFLAGS=["/TP"]) # assume all sources are C++
|
||||||
|
@ -344,11 +349,13 @@ def configure_mingw(env):
|
||||||
mingw_prefix = ""
|
mingw_prefix = ""
|
||||||
|
|
||||||
if env["bits"] == "32":
|
if env["bits"] == "32":
|
||||||
|
if env["use_static_cpp"]:
|
||||||
env.Append(LINKFLAGS=["-static"])
|
env.Append(LINKFLAGS=["-static"])
|
||||||
env.Append(LINKFLAGS=["-static-libgcc"])
|
env.Append(LINKFLAGS=["-static-libgcc"])
|
||||||
env.Append(LINKFLAGS=["-static-libstdc++"])
|
env.Append(LINKFLAGS=["-static-libstdc++"])
|
||||||
mingw_prefix = env["mingw_prefix_32"]
|
mingw_prefix = env["mingw_prefix_32"]
|
||||||
else:
|
else:
|
||||||
|
if env["use_static_cpp"]:
|
||||||
env.Append(LINKFLAGS=["-static"])
|
env.Append(LINKFLAGS=["-static"])
|
||||||
mingw_prefix = env["mingw_prefix_64"]
|
mingw_prefix = env["mingw_prefix_64"]
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue