From fdb7fa937a58900e3966adc765975785d0a9f0da Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Fri, 20 Feb 2015 11:07:09 +0100 Subject: Windows: Add -static-runtime configure option Support statically linking the MSVC/mingw runtime libraries without manually tweaking mkspecs. This is helpful for projects like the installer framework. MSVC does not support mixing MT[d]/MD[d] flags in different compilation units. The static_runtime option is therefore added to both QT_CONFIG and CONFIG. Change-Id: Ifd6dc9c362090457de8e2c62477d0445f9479722 Reviewed-by: Oswald Buddenhagen --- tools/configure/configureapp.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'tools') diff --git a/tools/configure/configureapp.cpp b/tools/configure/configureapp.cpp index ca2a5b1769..a263d44f29 100644 --- a/tools/configure/configureapp.cpp +++ b/tools/configure/configureapp.cpp @@ -245,6 +245,8 @@ Configure::Configure(int& argc, char** argv) dictionary[ "SHARED" ] = "yes"; + dictionary[ "STATIC_RUNTIME" ] = "no"; + dictionary[ "ZLIB" ] = "auto"; dictionary[ "PCRE" ] = "auto"; @@ -464,6 +466,8 @@ void Configure::parseCmdLine() dictionary[ "SHARED" ] = "yes"; else if (configCmdLine.at(i) == "-static") dictionary[ "SHARED" ] = "no"; + else if (configCmdLine.at(i) == "-static-runtime") + dictionary[ "STATIC_RUNTIME" ] = "yes"; else if (configCmdLine.at(i) == "-developer-build") dictionary[ "BUILDDEV" ] = "yes"; else if (configCmdLine.at(i) == "-opensource") { @@ -1775,6 +1779,8 @@ bool Configure::displayHelp() desc("SHARED", "yes", "-shared", "Create and use shared Qt libraries."); desc("SHARED", "no", "-static", "Create and use static Qt libraries.\n"); + desc("STATIC_RUNTIME", "no", "-static-runtime","Statically link the C/C++ runtime library.\n"); + desc("LTCG", "yes", "-ltcg", "Use Link Time Code Generation. (Release builds only)"); desc("LTCG", "no", "-no-ltcg", "Do not use Link Time Code Generation.\n"); @@ -2499,6 +2505,11 @@ bool Configure::verifyConfiguration() dictionary["C++11"] = "auto"; } + if (dictionary["STATIC_RUNTIME"] == "yes" && dictionary["SHARED"] == "yes") { + cout << "ERROR: -static-runtime requires -static" << endl << endl; + dictionary[ "DONE" ] = "error"; + } + if (dictionary["SEPARATE_DEBUG_INFO"] == "yes") { if (dictionary[ "SHARED" ] == "no") { cout << "ERROR: -separate-debug-info is incompatible with -static" << endl << endl; @@ -2644,6 +2655,9 @@ void Configure::generateOutputVars() else qtConfig += "shared"; + if (dictionary[ "STATIC_RUNTIME" ] == "yes") + qtConfig += "static_runtime"; + if (dictionary[ "GUI" ] == "no") { qtConfig += "no-gui"; dictionary [ "WIDGETS" ] = "no"; @@ -3362,6 +3376,8 @@ void Configure::generateQConfigPri() configStream << dictionary[ "BUILD" ]; configStream << (dictionary[ "SHARED" ] == "no" ? " static" : " shared"); + if (dictionary["STATIC_RUNTIME"] == "yes") + configStream << " static_runtime"; if (dictionary[ "LTCG" ] == "yes") configStream << " ltcg"; if (dictionary[ "RTTI" ] == "yes") -- cgit v1.2.3