From 4be8168ff7fe8c871a7f3cd7dce8fa4f70e1a6cf Mon Sep 17 00:00:00 2001 From: Oliver Wolff Date: Mon, 5 Nov 2018 11:16:28 +0100 Subject: Revert "Revert "qmake: Work around MSVC compiler bug."" The assert still happens on MSVC 2015 64 bit when running qmake -tp vc -r. This reverts commit f4169a633b97b7b6e7365172cf3d38d2f16a8914. Fixes: QTBUG-71228 Change-Id: I05bd3e0677414edb970f07e0555cdc95ce32f592 Reviewed-by: Friedemann Kleint --- qmake/generators/win32/msvc_vcproj.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'qmake/generators/win32') diff --git a/qmake/generators/win32/msvc_vcproj.cpp b/qmake/generators/win32/msvc_vcproj.cpp index f7837fc1b4..95c16661e7 100644 --- a/qmake/generators/win32/msvc_vcproj.cpp +++ b/qmake/generators/win32/msvc_vcproj.cpp @@ -208,6 +208,16 @@ struct VcsolutionDepend { QStringList dependencies; }; +/* Disable optimization in getProjectUUID() due to a compiler + * bug in MSVC 2015 that causes ASSERT: "&other != this" in the QString + * copy constructor for non-empty file names at: + * filename.isEmpty()?project->first("QMAKE_MAKEFILE"):filename */ + +#if defined(Q_CC_MSVC) && !defined(Q_CC_CLANG) +# pragma optimize( "g", off ) +# pragma warning ( disable : 4748 ) +#endif + QUuid VcprojGenerator::getProjectUUID(const QString &filename) { bool validUUID = true; @@ -239,6 +249,10 @@ QUuid VcprojGenerator::getProjectUUID(const QString &filename) return uuid; } +#if defined(Q_CC_MSVC) && !defined(Q_CC_CLANG) +# pragma optimize( "g", on ) +#endif + QUuid VcprojGenerator::increaseUUID(const QUuid &id) { QUuid result(id); -- cgit v1.2.3 From fbbe8aba9d70a3c13d1cd7797eb4dbbd1f05ade5 Mon Sep 17 00:00:00 2001 From: Thomas Miller Date: Mon, 15 Oct 2018 11:20:10 -0700 Subject: Add Windows Desktop arm64 target to Qtbase Allows a qt build to be configured to target arm64 desktop apps cross platform and build them with nmake. Change-Id: I99fed12047b45a504a1644201bcc19b18c69f3e6 Reviewed-by: Oswald Buddenhagen Reviewed-by: Oliver Wolff --- qmake/generators/win32/msvc_nmake.cpp | 46 ++++++++++++++++++++++++++--------- 1 file changed, 34 insertions(+), 12 deletions(-) (limited to 'qmake/generators/win32') diff --git a/qmake/generators/win32/msvc_nmake.cpp b/qmake/generators/win32/msvc_nmake.cpp index f2cd7c633b..306ae57871 100644 --- a/qmake/generators/win32/msvc_nmake.cpp +++ b/qmake/generators/win32/msvc_nmake.cpp @@ -71,18 +71,28 @@ NmakeMakefileGenerator::writeMakefile(QTextStream &t) return MakefileGenerator::writeStubMakefile(t); #endif if (!project->isHostBuild()) { + const QString msvcVer = project->first("MSVC_VER").toQString(); + if (msvcVer.isEmpty()) { + fprintf(stderr, "Mkspec does not specify MSVC_VER. Cannot continue.\n"); + return false; + } + + bool winrtBuild = false; + bool crossPlatformDesktopBuild = false; + QString arch = project->first("VCPROJ_ARCH").toQString().toLower(); if (project->isActiveConfig(QStringLiteral("winrt"))) { - QString arch = project->first("VCPROJ_ARCH").toQString().toLower(); + winrtBuild = true; + + // Only add explicit support for arm64 cross-platform desktop builds. + } else if ((arch == QLatin1String("arm64")) && (msvcVer == QStringLiteral("15.0"))) { + crossPlatformDesktopBuild = true; + } + + if (winrtBuild || crossPlatformDesktopBuild) { QString compiler; QString compilerArch; - const QString msvcVer = project->first("MSVC_VER").toQString(); - if (msvcVer.isEmpty()) { - fprintf(stderr, "Mkspec does not specify MSVC_VER. Cannot continue.\n"); - return false; - } - + const ProStringList hostArch = project->values("QMAKE_TARGET.arch"); if (msvcVer == QStringLiteral("15.0")) { - const ProStringList hostArch = project->values("QMAKE_TARGET.arch"); if (hostArch.contains("x86_64")) compiler = QStringLiteral("HostX64/"); else @@ -93,6 +103,9 @@ NmakeMakefileGenerator::writeMakefile(QTextStream &t) } else if (arch == QLatin1String("x64")) { compiler += QStringLiteral("x64"); compilerArch = QStringLiteral("amd64"); + } else if (arch == QLatin1String("arm64")) { + compiler += QStringLiteral("arm64"); + compilerArch = QStringLiteral("arm64"); } else { arch = QStringLiteral("x86"); compiler += QStringLiteral("x86"); @@ -119,7 +132,7 @@ NmakeMakefileGenerator::writeMakefile(QTextStream &t) return false; } const QString targetVer = project->first("WINTARGET_VER").toQString(); - if (targetVer.isEmpty()) { + if (targetVer.isEmpty() && winrtBuild) { fprintf(stderr, "Mkspec does not specify WINTARGET_VER. Cannot continue.\n"); return false; } @@ -181,10 +194,19 @@ NmakeMakefileGenerator::writeMakefile(QTextStream &t) incDirs << crtInclude + QStringLiteral("/shared"); incDirs << crtInclude + QStringLiteral("/winrt"); - incDirs << kitDir + QStringLiteral("Extension SDKs/WindowsMobile/") - + crtVersion + QStringLiteral("/Include/WinRT"); + if (winrtBuild) { + // Only use mobile-specific headers and link against store-specific libs for + // winrt builds. + incDirs << kitDir + QStringLiteral("Extension SDKs/WindowsMobile/") + + crtVersion + QStringLiteral("/Include/WinRT"); - libDirs << toolsInstallDir + QStringLiteral("lib/") + arch + QStringLiteral("/store"); + libDirs << toolsInstallDir + QStringLiteral("lib/") + arch + QStringLiteral("/store"); + } else { + // Desktop projects may require the atl headers and libs. + incDirs << toolsInstallDir + QStringLiteral("atlmfc/include"); + libDirs << toolsInstallDir + QStringLiteral("atlmfc/lib/") + compilerArch; + libDirs << toolsInstallDir + QStringLiteral("lib/") + arch; + } libDirs << vcInstallDir + QStringLiteral("VC/Auxiliary/VS/lib/") + arch; -- cgit v1.2.3 From 6e34552638cc4a6e71f90a36a7c6cea457b24fe1 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Fri, 20 Jul 2018 09:21:08 +0200 Subject: Enable users to specify WindowsTargetPlatform[Min]Version in VS projects [ChangeLog][qmake] Introduced the variables WINDOWS_TARGET_PLATFORM_VERSION and WINDOWS_TARGET_PLATFORM_MIN_VERSION for overriding the default values of WindowsTargetPlatformVersion and WindowsTargetPlatformMinVersion in Visual Studio project files. The code to determine the default values is moved to qmake feature files. A common/windows-desktop.conf file is introduced for variables common to all non-UWP Windows mkspecs. The package_manifest feature uses WINDOWS_TARGET_PLATFORM_VERSION as default value for WINRT_MANIFEST.minVersion, and WINDOWS_TARGET_PLATFORM_MIN_VERSION for WINRT_MANIFEST.maxVersionTested respectively. Task-number: QTBUG-53654 Change-Id: I251ec7f9b804c9bc9f7d571f5b43d52b2a2d99d3 Reviewed-by: Oswald Buddenhagen Reviewed-by: Oliver Wolff --- qmake/generators/win32/msbuild_objectmodel.cpp | 23 ++++------------------- qmake/generators/win32/msvc_objectmodel.h | 2 ++ qmake/generators/win32/msvc_vcproj.cpp | 4 ++++ 3 files changed, 10 insertions(+), 19 deletions(-) (limited to 'qmake/generators/win32') diff --git a/qmake/generators/win32/msbuild_objectmodel.cpp b/qmake/generators/win32/msbuild_objectmodel.cpp index ad2976aa01..0e95766f8e 100644 --- a/qmake/generators/win32/msbuild_objectmodel.cpp +++ b/qmake/generators/win32/msbuild_objectmodel.cpp @@ -34,7 +34,6 @@ #include #include #include -#include QT_BEGIN_NAMESPACE @@ -625,31 +624,17 @@ void VCXProjectWriter::write(XmlOutput &xml, VCProject &tool) << tagValue("RootNamespace", tool.Name) << tagValue("Keyword", tool.Keyword); - QString windowsTargetPlatformVersion; if (isWinRT) { xml << tagValue("MinimumVisualStudioVersion", tool.Version) << tagValue("DefaultLanguage", "en") << tagValue("AppContainerApplication", "true") << tagValue("ApplicationType", "Windows Store") << tagValue("ApplicationTypeRevision", tool.SdkVersion); - if (tool.SdkVersion == "10.0") - windowsTargetPlatformVersion = qgetenv("UCRTVERSION"); - } else { - QByteArray winSDKVersionStr = qgetenv("WindowsSDKVersion").trimmed(); - - // This environment variable might end with a backslash due to a VS bug. - if (winSDKVersionStr.endsWith('\\')) - winSDKVersionStr.chop(1); - - QVersionNumber winSDKVersion = QVersionNumber::fromString( - QString::fromLocal8Bit(winSDKVersionStr)); - if (!winSDKVersion.isNull()) - windowsTargetPlatformVersion = winSDKVersionStr; - } - if (!windowsTargetPlatformVersion.isEmpty()) { - xml << tagValue("WindowsTargetPlatformVersion", windowsTargetPlatformVersion) - << tagValue("WindowsTargetPlatformMinVersion", windowsTargetPlatformVersion); } + if (!tool.WindowsTargetPlatformVersion.isEmpty()) + xml << tagValue("WindowsTargetPlatformVersion", tool.WindowsTargetPlatformVersion); + if (!tool.WindowsTargetPlatformMinVersion.isEmpty()) + xml << tagValue("WindowsTargetPlatformMinVersion", tool.WindowsTargetPlatformMinVersion); xml << closetag(); diff --git a/qmake/generators/win32/msvc_objectmodel.h b/qmake/generators/win32/msvc_objectmodel.h index 9d1a170489..f8f9804c27 100644 --- a/qmake/generators/win32/msvc_objectmodel.h +++ b/qmake/generators/win32/msvc_objectmodel.h @@ -1123,6 +1123,8 @@ public: QString SccLocalPath; QString PlatformName; QString SdkVersion; + QString WindowsTargetPlatformVersion; + QString WindowsTargetPlatformMinVersion; // Single projects QList SingleProjects; diff --git a/qmake/generators/win32/msvc_vcproj.cpp b/qmake/generators/win32/msvc_vcproj.cpp index 95c16661e7..db2a16ae35 100644 --- a/qmake/generators/win32/msvc_vcproj.cpp +++ b/qmake/generators/win32/msvc_vcproj.cpp @@ -191,6 +191,10 @@ bool VcprojGenerator::writeProjectMakefile() mergedProject.SccProjectName = mergedProjects.at(0)->vcProject.SccProjectName; mergedProject.SccLocalPath = mergedProjects.at(0)->vcProject.SccLocalPath; mergedProject.PlatformName = mergedProjects.at(0)->vcProject.PlatformName; + mergedProject.WindowsTargetPlatformVersion = + project->first("WINDOWS_TARGET_PLATFORM_VERSION").toQString(); + mergedProject.WindowsTargetPlatformMinVersion = + project->first("WINDOWS_TARGET_PLATFORM_MIN_VERSION").toQString(); XmlOutput xmlOut(t); projectWriter->write(xmlOut, mergedProject); -- cgit v1.2.3 From e824136a3b850e7b2760bbef7b9572332ca4a285 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Thu, 22 Nov 2018 09:26:09 +0100 Subject: Rename VcProjGenerator::[autogen]precompCPP to [autogen]precompSource Those names are a better fit as we want to support C precompiled headers in a subsequent commit. Change-Id: Ie3f852da945b9b2cf0e363c81f1a4b3063f27372 Reviewed-by: Oliver Wolff --- qmake/generators/win32/msvc_objectmodel.cpp | 8 ++++---- qmake/generators/win32/msvc_vcproj.cpp | 14 +++++++------- qmake/generators/win32/msvc_vcproj.h | 4 ++-- 3 files changed, 13 insertions(+), 13 deletions(-) (limited to 'qmake/generators/win32') diff --git a/qmake/generators/win32/msvc_objectmodel.cpp b/qmake/generators/win32/msvc_objectmodel.cpp index 4f0cee65e1..442010a3a9 100644 --- a/qmake/generators/win32/msvc_objectmodel.cpp +++ b/qmake/generators/win32/msvc_objectmodel.cpp @@ -2213,8 +2213,8 @@ void VCFilter::addFiles(const ProStringList& fileList) void VCFilter::modifyPCHstage(QString str) { - bool autogenSourceFile = Project->autogenPrecompCPP; - bool pchThroughSourceFile = !Project->precompCPP.isEmpty(); + bool autogenSourceFile = Project->autogenPrecompSource; + bool pchThroughSourceFile = !Project->precompSource.isEmpty(); bool isCFile = false; for (QStringList::Iterator it = Option::c_ext.begin(); it != Option::c_ext.end(); ++it) { if (str.endsWith(*it)) { @@ -2223,7 +2223,7 @@ void VCFilter::modifyPCHstage(QString str) } } const bool isHFile = (str == Project->precompH); - bool isCPPFile = pchThroughSourceFile && (str == Project->precompCPP); + bool isCPPFile = pchThroughSourceFile && (str == Project->precompSource); if(!isCFile && !isHFile && !isCPPFile) return; @@ -2231,7 +2231,7 @@ void VCFilter::modifyPCHstage(QString str) if(isHFile && pchThroughSourceFile) { if (autogenSourceFile) { useCustomBuildTool = true; - QString toFile(Project->precompCPP); + QString toFile(Project->precompSource); CustomBuildTool.Description = "Generating precompiled header source file '" + toFile + "' ..."; CustomBuildTool.Outputs += toFile; diff --git a/qmake/generators/win32/msvc_vcproj.cpp b/qmake/generators/win32/msvc_vcproj.cpp index db2a16ae35..8c0b801891 100644 --- a/qmake/generators/win32/msvc_vcproj.cpp +++ b/qmake/generators/win32/msvc_vcproj.cpp @@ -775,7 +775,7 @@ void VcprojGenerator::init() // Setup PCH variables precompH = project->first("PRECOMPILED_HEADER").toQString(); - precompCPP = project->first("PRECOMPILED_SOURCE").toQString(); + precompSource = project->first("PRECOMPILED_SOURCE").toQString(); usePCH = !precompH.isEmpty() && project->isActiveConfig("precompile_header"); if (usePCH) { precompHFilename = fileInfo(precompH).fileName(); @@ -790,13 +790,13 @@ void VcprojGenerator::init() project->values("PRECOMPILED_OBJECT") = ProStringList(precompObj); project->values("PRECOMPILED_PCH") = ProStringList(precompPch); - autogenPrecompCPP = precompCPP.isEmpty() && project->isActiveConfig("autogen_precompile_source"); - if (autogenPrecompCPP) { - precompCPP = precompH + autogenPrecompSource = precompSource.isEmpty() && project->isActiveConfig("autogen_precompile_source"); + if (autogenPrecompSource) { + precompSource = precompH + (Option::cpp_ext.count() ? Option::cpp_ext.at(0) : QLatin1String(".cpp")); - project->values("GENERATED_SOURCES") += precompCPP; - } else if (!precompCPP.isEmpty()) { - project->values("SOURCES") += precompCPP; + project->values("GENERATED_SOURCES") += precompSource; + } else if (!precompSource.isEmpty()) { + project->values("SOURCES") += precompSource; } } diff --git a/qmake/generators/win32/msvc_vcproj.h b/qmake/generators/win32/msvc_vcproj.h index 6af5ec7007..fafc69d9ab 100644 --- a/qmake/generators/win32/msvc_vcproj.h +++ b/qmake/generators/win32/msvc_vcproj.h @@ -57,9 +57,9 @@ public: ~VcprojGenerator(); QString defaultMakefile() const; - QString precompH, precompHFilename, precompCPP, + QString precompH, precompHFilename, precompSource, precompObj, precompPch; - bool autogenPrecompCPP; + bool autogenPrecompSource; static bool hasBuiltinCompiler(const QString &file); QHash extraCompilerSources; -- cgit v1.2.3 From 54fc1b5ae6d87e6de233eb30f26e7c8d2cad05ba Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Thu, 22 Nov 2018 11:07:16 +0100 Subject: Remove variable autogenSourceFile from VCFilter::modifyPCHstage There's no point in having it, and this will reduce the diff of a subsequent commit. Change-Id: I3d27d6808c585b87a44df2499f2fcea4331befbb Reviewed-by: Oliver Wolff --- qmake/generators/win32/msvc_objectmodel.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'qmake/generators/win32') diff --git a/qmake/generators/win32/msvc_objectmodel.cpp b/qmake/generators/win32/msvc_objectmodel.cpp index 442010a3a9..30c2239232 100644 --- a/qmake/generators/win32/msvc_objectmodel.cpp +++ b/qmake/generators/win32/msvc_objectmodel.cpp @@ -2213,7 +2213,6 @@ void VCFilter::addFiles(const ProStringList& fileList) void VCFilter::modifyPCHstage(QString str) { - bool autogenSourceFile = Project->autogenPrecompSource; bool pchThroughSourceFile = !Project->precompSource.isEmpty(); bool isCFile = false; for (QStringList::Iterator it = Option::c_ext.begin(); it != Option::c_ext.end(); ++it) { @@ -2229,7 +2228,7 @@ void VCFilter::modifyPCHstage(QString str) return; if(isHFile && pchThroughSourceFile) { - if (autogenSourceFile) { + if (Project->autogenPrecompSource) { useCustomBuildTool = true; QString toFile(Project->precompSource); CustomBuildTool.Description = "Generating precompiled header source file '" + toFile + "' ..."; @@ -2266,7 +2265,7 @@ void VCFilter::modifyPCHstage(QString str) CompilerTool.UsePrecompiledHeader = (isCFile ? pchNone : pchCreateUsingSpecific); if (isCFile) CompilerTool.PrecompiledHeaderThrough = QLatin1String("$(NOINHERIT)"); - else if (autogenSourceFile) + else if (Project->autogenPrecompSource) CompilerTool.PrecompiledHeaderThrough = Project->precompHFilename; CompilerTool.ForcedIncludeFiles = QStringList("$(NOINHERIT)"); } -- cgit v1.2.3 From e5f94f0f0586b2240691f4b17be513b45feac440 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Thu, 22 Nov 2018 11:10:32 +0100 Subject: Simplify VCFilter::modifyPCHstage a bit Merge two nested if blocks. This reduces the diff size for a subsequent commit. Change-Id: If60938077169fc6686329cc5c30ebc97ada013a1 Reviewed-by: Oliver Wolff --- qmake/generators/win32/msvc_objectmodel.cpp | 56 ++++++++++++++--------------- 1 file changed, 27 insertions(+), 29 deletions(-) (limited to 'qmake/generators/win32') diff --git a/qmake/generators/win32/msvc_objectmodel.cpp b/qmake/generators/win32/msvc_objectmodel.cpp index 30c2239232..b9ecb14888 100644 --- a/qmake/generators/win32/msvc_objectmodel.cpp +++ b/qmake/generators/win32/msvc_objectmodel.cpp @@ -2227,36 +2227,34 @@ void VCFilter::modifyPCHstage(QString str) if(!isCFile && !isHFile && !isCPPFile) return; - if(isHFile && pchThroughSourceFile) { - if (Project->autogenPrecompSource) { - useCustomBuildTool = true; - QString toFile(Project->precompSource); - CustomBuildTool.Description = "Generating precompiled header source file '" + toFile + "' ..."; - CustomBuildTool.Outputs += toFile; - - QStringList lines; - CustomBuildTool.CommandLine += + if (isHFile && pchThroughSourceFile && Project->autogenPrecompSource) { + useCustomBuildTool = true; + QString toFile(Project->precompSource); + CustomBuildTool.Description = "Generating precompiled header source file '" + toFile + "' ..."; + CustomBuildTool.Outputs += toFile; + + QStringList lines; + CustomBuildTool.CommandLine += "echo /*-------------------------------------------------------------------- >" + toFile; - lines << "* Precompiled header source file used by Visual Studio.NET to generate"; - lines << "* the .pch file."; - lines << "*"; - lines << "* Due to issues with the dependencies checker within the IDE, it"; - lines << "* sometimes fails to recompile the PCH file, if we force the IDE to"; - lines << "* create the PCH file directly from the header file."; - lines << "*"; - lines << "* This file is auto-generated by qmake since no PRECOMPILED_SOURCE was"; - lines << "* specified, and is used as the common stdafx.cpp. The file is only"; - lines << QLatin1String("* generated when creating ") - + (Config->CompilerVersion < NET2010 ? ".vcproj" : ".vcxproj") - + " project files, and is not used for"; - lines << "* command line compilations by nmake."; - lines << "*"; - lines << "* WARNING: All changes made in this file will be lost."; - lines << "--------------------------------------------------------------------*/"; - lines << "#include \"" + Project->precompHFilename + "\""; - for (const QString &line : qAsConst(lines)) - CustomBuildTool.CommandLine += "echo " + line + ">>" + toFile; - } + lines << "* Precompiled header source file used by Visual Studio.NET to generate"; + lines << "* the .pch file."; + lines << "*"; + lines << "* Due to issues with the dependencies checker within the IDE, it"; + lines << "* sometimes fails to recompile the PCH file, if we force the IDE to"; + lines << "* create the PCH file directly from the header file."; + lines << "*"; + lines << "* This file is auto-generated by qmake since no PRECOMPILED_SOURCE was"; + lines << "* specified, and is used as the common stdafx.cpp. The file is only"; + lines << QLatin1String("* generated when creating ") + + (Config->CompilerVersion < NET2010 ? ".vcproj" : ".vcxproj") + + " project files, and is not used for"; + lines << "* command line compilations by nmake."; + lines << "*"; + lines << "* WARNING: All changes made in this file will be lost."; + lines << "--------------------------------------------------------------------*/"; + lines << "#include \"" + Project->precompHFilename + "\""; + for (const QString &line : qAsConst(lines)) + CustomBuildTool.CommandLine += "echo " + line + ">>" + toFile; return; } -- cgit v1.2.3 From e04aaf188c735b775dc4483099ec61a9372b0fa8 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Thu, 22 Nov 2018 09:35:38 +0100 Subject: Support 'CONFIG += precompile_header_c' in VS projects The CONFIG value precompile_header_c was ignored in the VS project generator. Add a member VcprojGenerator::pchIsCFile that is set to true if precompile_header_c is active. The code in modifyPCHstage had to be rearranged to separate the three parts for stable.h, stable.cpp and other files. Task-number: QTBUG-62821 Change-Id: I340eb165baa22cafcb64815cf223ce9a21aca558 Reviewed-by: Oliver Wolff --- qmake/generators/win32/msvc_objectmodel.cpp | 42 ++++++++++++++++------------- qmake/generators/win32/msvc_vcproj.cpp | 7 +++-- qmake/generators/win32/msvc_vcproj.h | 1 + 3 files changed, 29 insertions(+), 21 deletions(-) (limited to 'qmake/generators/win32') diff --git a/qmake/generators/win32/msvc_objectmodel.cpp b/qmake/generators/win32/msvc_objectmodel.cpp index b9ecb14888..7caa94c512 100644 --- a/qmake/generators/win32/msvc_objectmodel.cpp +++ b/qmake/generators/win32/msvc_objectmodel.cpp @@ -2213,20 +2213,8 @@ void VCFilter::addFiles(const ProStringList& fileList) void VCFilter::modifyPCHstage(QString str) { - bool pchThroughSourceFile = !Project->precompSource.isEmpty(); - bool isCFile = false; - for (QStringList::Iterator it = Option::c_ext.begin(); it != Option::c_ext.end(); ++it) { - if (str.endsWith(*it)) { - isCFile = true; - break; - } - } const bool isHFile = (str == Project->precompH); - bool isCPPFile = pchThroughSourceFile && (str == Project->precompSource); - - if(!isCFile && !isHFile && !isCPPFile) - return; - + const bool pchThroughSourceFile = !Project->precompSource.isEmpty(); if (isHFile && pchThroughSourceFile && Project->autogenPrecompSource) { useCustomBuildTool = true; QString toFile(Project->precompSource); @@ -2259,13 +2247,29 @@ void VCFilter::modifyPCHstage(QString str) } useCompilerTool = true; - // Setup PCH options - CompilerTool.UsePrecompiledHeader = (isCFile ? pchNone : pchCreateUsingSpecific); - if (isCFile) + const bool isPrecompSource = pchThroughSourceFile && (str == Project->precompSource); + if (isPrecompSource) { + CompilerTool.UsePrecompiledHeader = pchCreateUsingSpecific; + if (Project->autogenPrecompSource) + CompilerTool.PrecompiledHeaderThrough = Project->precompHFilename; + CompilerTool.ForcedIncludeFiles = QStringList("$(NOINHERIT)"); + return; + } + + bool isCFile = false; + for (QStringList::Iterator it = Option::c_ext.begin(); it != Option::c_ext.end(); ++it) { + if (str.endsWith(*it)) { + isCFile = true; + break; + } + } + + bool pchCompatible = (isCFile == Project->pchIsCFile); + if (!pchCompatible) { + CompilerTool.UsePrecompiledHeader = pchNone; CompilerTool.PrecompiledHeaderThrough = QLatin1String("$(NOINHERIT)"); - else if (Project->autogenPrecompSource) - CompilerTool.PrecompiledHeaderThrough = Project->precompHFilename; - CompilerTool.ForcedIncludeFiles = QStringList("$(NOINHERIT)"); + CompilerTool.ForcedIncludeFiles = QStringList("$(NOINHERIT)"); + } } VCFilterFile VCFilter::findFile(const QString &filePath, bool *found) const diff --git a/qmake/generators/win32/msvc_vcproj.cpp b/qmake/generators/win32/msvc_vcproj.cpp index 8c0b801891..6a125ccd77 100644 --- a/qmake/generators/win32/msvc_vcproj.cpp +++ b/qmake/generators/win32/msvc_vcproj.cpp @@ -776,7 +776,8 @@ void VcprojGenerator::init() // Setup PCH variables precompH = project->first("PRECOMPILED_HEADER").toQString(); precompSource = project->first("PRECOMPILED_SOURCE").toQString(); - usePCH = !precompH.isEmpty() && project->isActiveConfig("precompile_header"); + pchIsCFile = project->isActiveConfig("precompile_header_c"); + usePCH = !precompH.isEmpty() && (pchIsCFile || project->isActiveConfig("precompile_header")); if (usePCH) { precompHFilename = fileInfo(precompH).fileName(); // Created files @@ -793,7 +794,9 @@ void VcprojGenerator::init() autogenPrecompSource = precompSource.isEmpty() && project->isActiveConfig("autogen_precompile_source"); if (autogenPrecompSource) { precompSource = precompH - + (Option::cpp_ext.count() ? Option::cpp_ext.at(0) : QLatin1String(".cpp")); + + (pchIsCFile + ? (Option::c_ext.count() ? Option::c_ext.at(0) : QLatin1String(".c")) + : (Option::cpp_ext.count() ? Option::cpp_ext.at(0) : QLatin1String(".cpp"))); project->values("GENERATED_SOURCES") += precompSource; } else if (!precompSource.isEmpty()) { project->values("SOURCES") += precompSource; diff --git a/qmake/generators/win32/msvc_vcproj.h b/qmake/generators/win32/msvc_vcproj.h index fafc69d9ab..6f9743cb09 100644 --- a/qmake/generators/win32/msvc_vcproj.h +++ b/qmake/generators/win32/msvc_vcproj.h @@ -66,6 +66,7 @@ public: QHash extraCompilerOutputs; const QString customBuildToolFilterFileSuffix; bool usePCH; + bool pchIsCFile = false; VCProjectWriter *projectWriter; protected: -- cgit v1.2.3 From b98c43ea602b336813fa967e610da2be100f748d Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Thu, 18 Oct 2018 21:43:59 +0200 Subject: Compile with QT_STRICT_ITERATORS defined This will be the only options for Qt 6, so make sure the code compiles now. Change-Id: I23f791d1efcbd0bd33805bb4563d40460954db43 Reviewed-by: Oswald Buddenhagen --- qmake/generators/win32/msvc_vcproj.cpp | 4 ++-- qmake/generators/win32/winmakefile.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'qmake/generators/win32') diff --git a/qmake/generators/win32/msvc_vcproj.cpp b/qmake/generators/win32/msvc_vcproj.cpp index 6a125ccd77..d231260886 100644 --- a/qmake/generators/win32/msvc_vcproj.cpp +++ b/qmake/generators/win32/msvc_vcproj.cpp @@ -477,8 +477,8 @@ ProStringList VcprojGenerator::collectDependencies(QMakeProject *proj, QHash Date: Fri, 7 Dec 2018 10:36:08 +0100 Subject: Fix qmake's detection for conflicting source files for nmake Consider the following source tree: foo/narf.cpp bar/narf.c bar/gnampf.cpp The .pro file has SOURCES += foo/narf.cpp bar/gnampf.cpp The file bar/narf.c is not supposed to be built for whatever reason. QMake's nmake Makefile generator generates inference rules of the form {.\foo}.cpp{debug\}.obj:: ... for every source subdirectory and every source file extension. Thus, we have {.\foo}.cpp{debug\}.obj:: {.\bar}.cpp{debug\}.obj:: {.\bar}.c{debug\}.obj:: Depending on the exact execution order of the inference rules (which depends on the names of the files) the latter rule might get picked, and we're erronously compiling bar/narf.c even though it's not referenced in the .pro file. Conclusion: QMake's detection of conflicting source files must consider the base names of source files, and not the exact file names. Fixes: QTBUG-72059 Change-Id: I50c2725ae2a7421053369a10680230f571af00ea Reviewed-by: Oliver Wolff Reviewed-by: Oswald Buddenhagen --- qmake/generators/win32/msvc_nmake.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'qmake/generators/win32') diff --git a/qmake/generators/win32/msvc_nmake.cpp b/qmake/generators/win32/msvc_nmake.cpp index 306ae57871..780f6bd4d8 100644 --- a/qmake/generators/win32/msvc_nmake.cpp +++ b/qmake/generators/win32/msvc_nmake.cpp @@ -553,12 +553,13 @@ void NmakeMakefileGenerator::writeImplicitRulesPart(QTextStream &t) QDirIterator dit(sourceDir, sourceFilesFilter, QDir::Files | QDir::NoDotAndDotDot); while (dit.hasNext()) { dit.next(); - QString &duplicate = fileNames[dit.fileName()]; + const QFileInfo fi = dit.fileInfo(); + QString &duplicate = fileNames[fi.completeBaseName()]; if (duplicate.isNull()) { - duplicate = dit.filePath(); + duplicate = fi.filePath(); } else { warn_msg(WarnLogic, "%s conflicts with %s", qPrintable(duplicate), - qPrintable(dit.filePath())); + qPrintable(fi.filePath())); duplicatesFound = true; } } -- cgit v1.2.3 From 91d98321d361b4304265e09dba227df9fdc78393 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Fri, 14 Dec 2018 20:20:56 +0100 Subject: qmake: move QT_BEGIN_NAMESPACE to correct place this makes no difference whatsoever, because qmake isn't actually built in a namespace, but it makes the new qtc code model happy. Change-Id: I70ad8e16cceff73276a821219fc80bab365954b5 Reviewed-by: Joerg Bornemann --- qmake/generators/win32/registry_p.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'qmake/generators/win32') diff --git a/qmake/generators/win32/registry_p.h b/qmake/generators/win32/registry_p.h index 3526dffd45..f9e8bba016 100644 --- a/qmake/generators/win32/registry_p.h +++ b/qmake/generators/win32/registry_p.h @@ -40,8 +40,6 @@ // We mean it. // -QT_BEGIN_NAMESPACE - #include #ifdef Q_OS_WIN32 @@ -52,6 +50,8 @@ QT_BEGIN_NAMESPACE #include +QT_BEGIN_NAMESPACE + /** * Read a value from the Windows registry. * -- cgit v1.2.3 From f9d8762d37d83e3f3f21adfece0dbbb15886d722 Mon Sep 17 00:00:00 2001 From: Oliver Wolff Date: Fri, 21 Dec 2018 09:38:30 +0100 Subject: winrt: Remove yet another Windows Phone leftover Hardware and camera button handling are phone specific APIs we no longer support in Qt. Change-Id: Ib11f894a426b8e4b71acf24876437ddab2cea548 Reviewed-by: Oliver Wolff Reviewed-by: Andre de la Rocha Reviewed-by: Oswald Buddenhagen --- qmake/generators/win32/msvc_nmake.cpp | 8 -------- 1 file changed, 8 deletions(-) (limited to 'qmake/generators/win32') diff --git a/qmake/generators/win32/msvc_nmake.cpp b/qmake/generators/win32/msvc_nmake.cpp index 780f6bd4d8..548d2e8575 100644 --- a/qmake/generators/win32/msvc_nmake.cpp +++ b/qmake/generators/win32/msvc_nmake.cpp @@ -195,11 +195,6 @@ NmakeMakefileGenerator::writeMakefile(QTextStream &t) incDirs << crtInclude + QStringLiteral("/winrt"); if (winrtBuild) { - // Only use mobile-specific headers and link against store-specific libs for - // winrt builds. - incDirs << kitDir + QStringLiteral("Extension SDKs/WindowsMobile/") - + crtVersion + QStringLiteral("/Include/WinRT"); - libDirs << toolsInstallDir + QStringLiteral("lib/") + arch + QStringLiteral("/store"); } else { // Desktop projects may require the atl headers and libs. @@ -236,9 +231,6 @@ NmakeMakefileGenerator::writeMakefile(QTextStream &t) incDirs << crtInclude + QStringLiteral("/shared"); incDirs << crtInclude + QStringLiteral("/winrt"); - incDirs << kitDir + QStringLiteral("Extension SDKs/WindowsMobile/") - + crtVersion + QStringLiteral("/Include/WinRT"); - libDirs << vcInstallDir + QStringLiteral("lib/store/") + compilerArch; libDirs << vcInstallDir + QStringLiteral("atlmfc/lib") + compilerArch; -- cgit v1.2.3 From fff59911a353b3fcf74369d8459ac79ce350a54d Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Fri, 14 Dec 2018 20:13:44 +0100 Subject: qmake: add QMAKE_EXPORTED_VARIABLES because QMAKE_EXTRA_VARIABLES sometimes just ain't enough. Change-Id: I739e5b6510e4701ca0a86834e4f9a978d7ef1cf4 Reviewed-by: Joerg Bornemann --- qmake/generators/win32/winmakefile.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'qmake/generators/win32') diff --git a/qmake/generators/win32/winmakefile.cpp b/qmake/generators/win32/winmakefile.cpp index e0d03ccc1c..91215c94b1 100644 --- a/qmake/generators/win32/winmakefile.cpp +++ b/qmake/generators/win32/winmakefile.cpp @@ -520,6 +520,8 @@ void Win32MakefileGenerator::writeIncPart(QTextStream &t) void Win32MakefileGenerator::writeStandardParts(QTextStream &t) { + writeExportedVariables(t); + t << "####### Compiler, tools and options\n\n"; t << "CC = " << var("QMAKE_CC") << endl; t << "CXX = " << var("QMAKE_CXX") << endl; -- cgit v1.2.3 From f89ac0101ad4a6cb5339a3bfe132aad897eafc9d Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Fri, 14 Dec 2018 21:12:11 +0100 Subject: qmake: add $$read_registry() function Change-Id: I7f9f17e0f44c273e4754d1decc92a8594cad8658 Reviewed-by: Simon Hausmann --- qmake/generators/win32/registry.cpp | 158 ------------------------------------ qmake/generators/win32/registry_p.h | 73 ----------------- 2 files changed, 231 deletions(-) delete mode 100644 qmake/generators/win32/registry.cpp delete mode 100644 qmake/generators/win32/registry_p.h (limited to 'qmake/generators/win32') diff --git a/qmake/generators/win32/registry.cpp b/qmake/generators/win32/registry.cpp deleted file mode 100644 index 3391ab9512..0000000000 --- a/qmake/generators/win32/registry.cpp +++ /dev/null @@ -1,158 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the qmake application of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include "registry_p.h" - -QT_BEGIN_NAMESPACE - -#ifdef Q_OS_WIN32 -/* - Returns the path part of a registry key. - e.g. - For a key - "Software\\Microsoft\\VisualStudio\\8.0\\Setup\\VC\\ProductDir" - it returns - "Software\\Microsoft\\VisualStudio\\8.0\\Setup\\VC\\" -*/ -static QString keyPath(const QString &rKey) -{ - int idx = rKey.lastIndexOf(QLatin1Char('\\')); - if (idx == -1) - return QString(); - return rKey.left(idx + 1); -} - -/* - Returns the name part of a registry key. - e.g. - For a key - "Software\\Microsoft\\VisualStudio\\8.0\\Setup\\VC\\ProductDir" - it returns - "ProductDir" -*/ -static QString keyName(const QString &rKey) -{ - int idx = rKey.lastIndexOf(QLatin1Char('\\')); - if (idx == -1) - return rKey; - - QString res(rKey.mid(idx + 1)); - if (res == QLatin1String("Default") || res == QLatin1String(".")) - res = QString(); - return res; -} -#endif - -QString qt_readRegistryKey(HKEY parentHandle, const QString &rSubkey, unsigned long options) -{ - QString result; - -#ifdef Q_OS_WIN32 - QString rSubkeyName = keyName(rSubkey); - QString rSubkeyPath = keyPath(rSubkey); - - HKEY handle = nullptr; - LONG res = RegOpenKeyEx(parentHandle, (wchar_t*)rSubkeyPath.utf16(), 0, - KEY_READ | options, &handle); - - if (res != ERROR_SUCCESS) - return QString(); - - // get the size and type of the value - DWORD dataType; - DWORD dataSize; - res = RegQueryValueEx(handle, (wchar_t*)rSubkeyName.utf16(), nullptr, &dataType, nullptr, &dataSize); - if (res != ERROR_SUCCESS) { - RegCloseKey(handle); - return QString(); - } - - // get the value - QByteArray data(dataSize, 0); - res = RegQueryValueEx(handle, (wchar_t*)rSubkeyName.utf16(), nullptr, nullptr, - reinterpret_cast(data.data()), &dataSize); - if (res != ERROR_SUCCESS) { - RegCloseKey(handle); - return QString(); - } - - switch (dataType) { - case REG_EXPAND_SZ: - case REG_SZ: { - result = QString::fromWCharArray(((const wchar_t *)data.constData())); - break; - } - - case REG_MULTI_SZ: { - QStringList l; - int i = 0; - for (;;) { - QString s = QString::fromWCharArray((const wchar_t *)data.constData() + i); - i += s.length() + 1; - - if (s.isEmpty()) - break; - l.append(s); - } - result = l.join(QLatin1String(", ")); - break; - } - - case REG_NONE: - case REG_BINARY: { - result = QString::fromWCharArray((const wchar_t *)data.constData(), data.size() / 2); - break; - } - - case REG_DWORD_BIG_ENDIAN: - case REG_DWORD: { - Q_ASSERT(data.size() == sizeof(int)); - int i; - memcpy((char*)&i, data.constData(), sizeof(int)); - result = QString::number(i); - break; - } - - default: - qWarning("QSettings: unknown data %u type in windows registry", quint32(dataType)); - break; - } - - RegCloseKey(handle); -#else - Q_UNUSED(parentHandle); - Q_UNUSED(rSubkey) - Q_UNUSED(options); -#endif - - return result; -} - -QT_END_NAMESPACE - diff --git a/qmake/generators/win32/registry_p.h b/qmake/generators/win32/registry_p.h deleted file mode 100644 index f9e8bba016..0000000000 --- a/qmake/generators/win32/registry_p.h +++ /dev/null @@ -1,73 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the qmake application of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QT_WINDOWS_REGISTRY_H -#define QT_WINDOWS_REGISTRY_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include - -#ifdef Q_OS_WIN32 - #include -#else - typedef void* HKEY; -#endif - -#include - -QT_BEGIN_NAMESPACE - -/** - * Read a value from the Windows registry. - * - * If the key is not found, or the registry cannot be accessed (for example - * if this code is compiled for a platform other than Windows), a null - * string is returned. - * - * 32-bit code reads from the registry's 32 bit view (Wow6432Node), - * 64 bit code reads from the 64 bit view. - * Pass KEY_WOW64_32KEY to access the 32 bit view regardless of the - * application's architecture, KEY_WOW64_64KEY respectively. - */ -QString qt_readRegistryKey(HKEY parentHandle, const QString &rSubkey, - unsigned long options = 0); - -QT_END_NAMESPACE - -#endif // QT_WINDOWS_REGISTRY_H - -- cgit v1.2.3 From 45e4dfb449fb15632e5144cf671e38943fa1455f Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Mon, 17 Dec 2018 20:57:18 +0100 Subject: qmake: rewrite msvc/nmake cross-build environment setup rather than reproducing vcvarsall.bat's functionality as hard-wired code in the nmake generator, just invoke the actual script from toolchain.prf. this is much easier, more future proof, and - critically - makes the detected variables available to configure's new library & header search facilities. [ChangeLog][Important Behavior Changes][qmake][WinRT] Cross-builds will now ignore pre-set values of %INCLUDE% and %LIB% when building target executables. If necessary, use configure's -I and -L switches when building Qt, and pass QMAKE_INCDIR and QMAKE_LIBDIR on qmake's command line when building own projects. Change-Id: I36f53e8880d6523f3f6f7a44d40d87d04bd06854 Reviewed-by: Thomas Miller Reviewed-by: Oliver Wolff --- qmake/generators/win32/msvc_nmake.cpp | 201 ---------------------------------- 1 file changed, 201 deletions(-) (limited to 'qmake/generators/win32') diff --git a/qmake/generators/win32/msvc_nmake.cpp b/qmake/generators/win32/msvc_nmake.cpp index 548d2e8575..aa3d389b67 100644 --- a/qmake/generators/win32/msvc_nmake.cpp +++ b/qmake/generators/win32/msvc_nmake.cpp @@ -34,23 +34,10 @@ #include #include -#include - #include QT_BEGIN_NAMESPACE -static QString nmakePathList(const QStringList &list) -{ - QStringList pathList; - pathList.reserve(list.size()); - for (const QString &path : list) - pathList.append(QDir::cleanPath(path)); - - return QDir::toNativeSeparators(pathList.join(QLatin1Char(';'))) - .replace('#', QLatin1String("^#")).replace('$', QLatin1String("$$")); -} - NmakeMakefileGenerator::NmakeMakefileGenerator() : usePCH(false), usePCHC(false) { @@ -70,194 +57,6 @@ NmakeMakefileGenerator::writeMakefile(QTextStream &t) if(Option::mkfile::do_stub_makefile) return MakefileGenerator::writeStubMakefile(t); #endif - if (!project->isHostBuild()) { - const QString msvcVer = project->first("MSVC_VER").toQString(); - if (msvcVer.isEmpty()) { - fprintf(stderr, "Mkspec does not specify MSVC_VER. Cannot continue.\n"); - return false; - } - - bool winrtBuild = false; - bool crossPlatformDesktopBuild = false; - QString arch = project->first("VCPROJ_ARCH").toQString().toLower(); - if (project->isActiveConfig(QStringLiteral("winrt"))) { - winrtBuild = true; - - // Only add explicit support for arm64 cross-platform desktop builds. - } else if ((arch == QLatin1String("arm64")) && (msvcVer == QStringLiteral("15.0"))) { - crossPlatformDesktopBuild = true; - } - - if (winrtBuild || crossPlatformDesktopBuild) { - QString compiler; - QString compilerArch; - const ProStringList hostArch = project->values("QMAKE_TARGET.arch"); - if (msvcVer == QStringLiteral("15.0")) { - if (hostArch.contains("x86_64")) - compiler = QStringLiteral("HostX64/"); - else - compiler = QStringLiteral("HostX86/"); - if (arch == QLatin1String("arm")) { - compiler += QStringLiteral("arm"); - compilerArch = QStringLiteral("arm"); - } else if (arch == QLatin1String("x64")) { - compiler += QStringLiteral("x64"); - compilerArch = QStringLiteral("amd64"); - } else if (arch == QLatin1String("arm64")) { - compiler += QStringLiteral("arm64"); - compilerArch = QStringLiteral("arm64"); - } else { - arch = QStringLiteral("x86"); - compiler += QStringLiteral("x86"); - } - } else { - if (arch == QLatin1String("arm")) { - compiler = QStringLiteral("x86_arm"); - compilerArch = QStringLiteral("arm"); - } else if (arch == QLatin1String("x64")) { - const ProStringList hostArch = project->values("QMAKE_TARGET.arch"); - if (hostArch.contains("x86_64")) - compiler = QStringLiteral("amd64"); - else - compiler = QStringLiteral("x86_amd64"); - compilerArch = QStringLiteral("amd64"); - } else { - arch = QStringLiteral("x86"); - } - } - - const QString winsdkVer = project->first("WINSDK_VER").toQString(); - if (winsdkVer.isEmpty()) { - fprintf(stderr, "Mkspec does not specify WINSDK_VER. Cannot continue.\n"); - return false; - } - const QString targetVer = project->first("WINTARGET_VER").toQString(); - if (targetVer.isEmpty() && winrtBuild) { - fprintf(stderr, "Mkspec does not specify WINTARGET_VER. Cannot continue.\n"); - return false; - } - -#ifdef Q_OS_WIN - QString regKey; - if (msvcVer == QStringLiteral("15.0")) - regKey = QStringLiteral("Software\\Microsoft\\VisualStudio\\SxS\\VS7\\") + msvcVer; - else - regKey = QStringLiteral("Software\\Microsoft\\VisualStudio\\") + msvcVer + ("\\Setup\\VC\\ProductDir"); - const QString vcInstallDir = qt_readRegistryKey(HKEY_LOCAL_MACHINE, regKey, KEY_WOW64_32KEY); - if (vcInstallDir.isEmpty()) { - fprintf(stderr, "Failed to find the Visual Studio installation directory.\n"); - return false; - } - - const QString windowsPath = "Software\\Microsoft\\Microsoft SDKs\\Windows\\v"; - - regKey = windowsPath + winsdkVer + QStringLiteral("\\InstallationFolder"); - const QString kitDir = qt_readRegistryKey(HKEY_LOCAL_MACHINE, regKey, KEY_WOW64_32KEY); - if (kitDir.isEmpty()) { - fprintf(stderr, "Failed to find the Windows Kit installation directory.\n"); - return false; - } -#else - const QString vcInstallDir = "/fake/vc_install_dir"; - const QString kitDir = "/fake/sdk_install_dir"; -#endif // Q_OS_WIN - QStringList incDirs; - QStringList libDirs; - QStringList binDirs; - if (msvcVer == QStringLiteral("15.0")) { - const QString toolsInstallDir = qgetenv("VCToolsInstallDir"); - if (toolsInstallDir.isEmpty()) { - fprintf(stderr, "Failed to access tools installation dir.\n"); - return false; - } - - binDirs << toolsInstallDir + QStringLiteral("bin/") + compiler; - if (arch == QStringLiteral("x64")) - binDirs << toolsInstallDir + QStringLiteral("bin/HostX86/X86"); - binDirs << kitDir + QStringLiteral("bin/x86"); - binDirs << vcInstallDir + QStringLiteral("Common7/Tools"); - binDirs << vcInstallDir + QStringLiteral("Common7/ide"); - binDirs << vcInstallDir + QStringLiteral("MSBuild/15.0/bin"); - - incDirs << toolsInstallDir + QStringLiteral("include"); - incDirs << vcInstallDir + QStringLiteral("VC/Auxiliary/VS/include"); - - const QString crtVersion = qgetenv("UCRTVersion"); - if (crtVersion.isEmpty()) { - fprintf(stderr, "Failed to access CRT version.\n"); - return false; - } - const QString crtInclude = kitDir + QStringLiteral("Include/") + crtVersion; - const QString crtLib = kitDir + QStringLiteral("Lib/") + crtVersion; - incDirs << crtInclude + QStringLiteral("/ucrt"); - incDirs << crtInclude + QStringLiteral("/um"); - incDirs << crtInclude + QStringLiteral("/shared"); - incDirs << crtInclude + QStringLiteral("/winrt"); - - if (winrtBuild) { - libDirs << toolsInstallDir + QStringLiteral("lib/") + arch + QStringLiteral("/store"); - } else { - // Desktop projects may require the atl headers and libs. - incDirs << toolsInstallDir + QStringLiteral("atlmfc/include"); - libDirs << toolsInstallDir + QStringLiteral("atlmfc/lib/") + compilerArch; - libDirs << toolsInstallDir + QStringLiteral("lib/") + arch; - } - - libDirs << vcInstallDir + QStringLiteral("VC/Auxiliary/VS/lib/") + arch; - - libDirs << crtLib + QStringLiteral("/ucrt/") + arch; - libDirs << crtLib + QStringLiteral("/um/") + arch; - } else if (msvcVer == QStringLiteral("14.0")) { - binDirs << vcInstallDir + QStringLiteral("bin/") + compiler; - binDirs << vcInstallDir + QStringLiteral("bin/"); // Maybe remove for x86 again? - binDirs << kitDir + QStringLiteral("bin/") + (arch == QStringLiteral("arm") ? QStringLiteral("x86") : arch); - binDirs << vcInstallDir + QStringLiteral("../Common7/Tools/bin"); - binDirs << vcInstallDir + QStringLiteral("../Common7/Tools"); - binDirs << vcInstallDir + QStringLiteral("../Common7/ide"); - binDirs << kitDir + QStringLiteral("Windows Performance Toolkit/"); - - incDirs << vcInstallDir + QStringLiteral("include"); - incDirs << vcInstallDir + QStringLiteral("atlmfc/include"); - - const QString crtVersion = qgetenv("UCRTVersion"); - if (crtVersion.isEmpty()) { - fprintf(stderr, "Failed to access CRT version.\n"); - return false; - } - const QString crtInclude = kitDir + QStringLiteral("Include/") + crtVersion; - const QString crtLib = kitDir + QStringLiteral("Lib/") + crtVersion; - incDirs << crtInclude + QStringLiteral("/ucrt"); - incDirs << crtInclude + QStringLiteral("/um"); - incDirs << crtInclude + QStringLiteral("/shared"); - incDirs << crtInclude + QStringLiteral("/winrt"); - - libDirs << vcInstallDir + QStringLiteral("lib/store/") + compilerArch; - libDirs << vcInstallDir + QStringLiteral("atlmfc/lib") + compilerArch; - - libDirs << crtLib + QStringLiteral("/ucrt/") + arch; - libDirs << crtLib + QStringLiteral("/um/") + arch; - } else { - incDirs << vcInstallDir + QStringLiteral("/include"); - libDirs << vcInstallDir + QStringLiteral("/lib/store/") + compilerArch - << vcInstallDir + QStringLiteral("/lib/") + compilerArch; - binDirs << vcInstallDir + QStringLiteral("/bin/") + compiler - << vcInstallDir + QStringLiteral("/../Common7/IDE"); - libDirs << kitDir + QStringLiteral("/Lib/") + targetVer + ("/um/") + arch; - incDirs << kitDir + QStringLiteral("/include/um") - << kitDir + QStringLiteral("/include/shared") - << kitDir + QStringLiteral("/include/winrt"); - } - - binDirs << vcInstallDir + QStringLiteral("/bin"); - - // Inherit PATH - binDirs << QString::fromLocal8Bit(qgetenv("PATH")).split(QLatin1Char(';')); - - t << "\nINCLUDE = " << nmakePathList(incDirs); - t << "\nLIB = " << nmakePathList(libDirs); - t << "\nPATH = " << nmakePathList(binDirs) << '\n'; - } - } writeNmakeParts(t); return MakefileGenerator::writeMakefile(t); } -- cgit v1.2.3 From 2327944d241f48495a7b867b8e206a4c8c5d52e3 Mon Sep 17 00:00:00 2001 From: Samuli Piippo Date: Mon, 7 Jan 2019 10:29:53 +0200 Subject: qmake: use default libdirs to search for prl libs Default libdirs are never added to the modules' LIBS and if Qt was configured to use one of the default libdirs, module might end up without any path to search for its prl files. Add default libdirs to the search path similar as it's done in unix/makefile generator. Fixes: QTBUG-72855 Change-Id: I43c5bae0d54ba9427ab0ad3eab61ba0c4e2cbde8 Reviewed-by: Joerg Bornemann --- qmake/generators/win32/winmakefile.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'qmake/generators/win32') diff --git a/qmake/generators/win32/winmakefile.cpp b/qmake/generators/win32/winmakefile.cpp index 91215c94b1..6046e5791e 100644 --- a/qmake/generators/win32/winmakefile.cpp +++ b/qmake/generators/win32/winmakefile.cpp @@ -84,6 +84,8 @@ Win32MakefileGenerator::findLibraries(bool linkPrl, bool mergeLflags) if (impexts.isEmpty()) impexts = project->values("QMAKE_EXTENSION_STATICLIB"); QList dirs; + for (const ProString &dlib : project->values("QMAKE_DEFAULT_LIBDIRS")) + dirs.append(QMakeLocalFileName(dlib.toQString())); static const char * const lflags[] = { "LIBS", "LIBS_PRIVATE", "QMAKE_LIBS", "QMAKE_LIBS_PRIVATE", nullptr }; for (int i = 0; lflags[i]; i++) { -- cgit v1.2.3 From 29d5a287abc3d3c9b75619db18042dea66236cb3 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Fri, 1 Feb 2019 10:54:30 +0100 Subject: Make the Makefile a dependency of default targets for nmake If the user changes the .pro file, the Makefile is supposed to be re-generated by calling qmake again. NMake however lacks a "Makefile remake feature" like GNU make has. The generated Makefiles for nmake however have already a proper Makefile target that can be used to re-generate the Makefile. What was missing is the dependency from an entry-target in the meta-Makefile. Now changes in the .pro file trigger a re-generation of Makefile.Debug/Makefile.Release when calling nmake without target arguments or with "debug" or "release". Fixes: QTBUG-29193 Change-Id: I9f2dd5deba4a043ab6c9502bb0b0ba83dc843612 Reviewed-by: Oliver Wolff --- qmake/generators/win32/msvc_nmake.cpp | 5 +++++ qmake/generators/win32/msvc_nmake.h | 1 + 2 files changed, 6 insertions(+) (limited to 'qmake/generators/win32') diff --git a/qmake/generators/win32/msvc_nmake.cpp b/qmake/generators/win32/msvc_nmake.cpp index aa3d389b67..a6e850a036 100644 --- a/qmake/generators/win32/msvc_nmake.cpp +++ b/qmake/generators/win32/msvc_nmake.cpp @@ -76,6 +76,11 @@ void NmakeMakefileGenerator::writeSubMakeCall(QTextStream &t, const QString &cal Win32MakefileGenerator::writeSubMakeCall(t, callPrefix, makeArguments); } +ProStringList NmakeMakefileGenerator::extraSubTargetDependencies() +{ + return { "$(MAKEFILE)" }; +} + QString NmakeMakefileGenerator::defaultInstall(const QString &t) { QString ret = Win32MakefileGenerator::defaultInstall(t); diff --git a/qmake/generators/win32/msvc_nmake.h b/qmake/generators/win32/msvc_nmake.h index 67a56c7813..5bfdba2bbc 100644 --- a/qmake/generators/win32/msvc_nmake.h +++ b/qmake/generators/win32/msvc_nmake.h @@ -48,6 +48,7 @@ class NmakeMakefileGenerator : public Win32MakefileGenerator protected: void writeSubMakeCall(QTextStream &t, const QString &callPrefix, const QString &makeArguments) override; + ProStringList extraSubTargetDependencies() override; QString defaultInstall(const QString &t) override; QStringList &findDependencies(const QString &file) override; QString var(const ProKey &value) const override; -- cgit v1.2.3 From 2dcfaf7bee9e74546b96481554ba06d5dcb29cfa Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Wed, 30 Jan 2019 13:44:54 +0100 Subject: qmake/vcxproj generator: Fix bug in extra compiler initialization QMake ignored every extra compiler that sets variable_out and whose output does not have a builtin compiler (C++, C). What the code wants to achieve is to ignore extra compilers that put their output into variables that are handled "somewhere else already", e.g. are in the otherFilters list. Evidence for that is to be found in the addOnInput == true if branch. Task-number: QTBUG-71283 Change-Id: I8c1d76febccacb450cd14ad7a1f4b87726832312 Reviewed-by: Brett Stottlemyer Reviewed-by: Edward Welbourne Reviewed-by: Oliver Wolff --- qmake/generators/win32/msvc_vcproj.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'qmake/generators/win32') diff --git a/qmake/generators/win32/msvc_vcproj.cpp b/qmake/generators/win32/msvc_vcproj.cpp index 95c16661e7..a81e540e1f 100644 --- a/qmake/generators/win32/msvc_vcproj.cpp +++ b/qmake/generators/win32/msvc_vcproj.cpp @@ -1541,14 +1541,14 @@ void VcprojGenerator::initExtraCompilerOutputs() extraCompile.Filter = ""; extraCompile.Guid = QString(_GUIDExtraCompilerFiles) + "-" + (*it); - // If the extra compiler has a variable_out set the output file - // is added to an other file list, and does not need its own.. bool addOnInput = hasBuiltinCompiler(firstExpandedOutputFileName(*it)); - const ProString &tmp_other_out = project->first(ProKey(*it + ".variable_out")); - if (!tmp_other_out.isEmpty() && !addOnInput) - continue; - if (!addOnInput) { + // If the extra compiler has a variable_out set that is already handled + // some other place, ignore it. + const ProString &outputVar = project->first(ProKey(*it + ".variable_out")); + if (!outputVar.isEmpty() && otherFilters.contains(outputVar)) + continue; + QString tmp_out = project->first(ProKey(*it + ".output")).toQString(); if (project->values(ProKey(*it + ".CONFIG")).indexOf("combine") != -1) { // Combined output, only one file result -- cgit v1.2.3 From 4aafe68e1ac12ab0f897828f9f8c2930a68fac95 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Tue, 12 Feb 2019 09:23:28 +0100 Subject: qmake vcxproj generator: Update platform toolset and solution header for VS 2019 Change-Id: Id01f28f2ef3e271fa48dddf5f8ccb6b057180aa0 Reviewed-by: Joerg Bornemann --- qmake/generators/win32/msvc_objectmodel.cpp | 3 ++- qmake/generators/win32/msvc_objectmodel.h | 3 ++- qmake/generators/win32/msvc_vcproj.cpp | 10 ++++++++++ 3 files changed, 14 insertions(+), 2 deletions(-) (limited to 'qmake/generators/win32') diff --git a/qmake/generators/win32/msvc_objectmodel.cpp b/qmake/generators/win32/msvc_objectmodel.cpp index 4f0cee65e1..7335211f30 100644 --- a/qmake/generators/win32/msvc_objectmodel.cpp +++ b/qmake/generators/win32/msvc_objectmodel.cpp @@ -55,7 +55,8 @@ static DotNET vsVersionFromString(const char *versionString) { "11.0", NET2012 }, { "12.0", NET2013 }, { "14.0", NET2015 }, - { "15.0", NET2017 } + { "15.0", NET2017 }, + { "16.0", NET2019 } }; DotNET result = NETUnknown; for (const auto entry : mapping) { diff --git a/qmake/generators/win32/msvc_objectmodel.h b/qmake/generators/win32/msvc_objectmodel.h index 9d1a170489..41a6ffafa7 100644 --- a/qmake/generators/win32/msvc_objectmodel.h +++ b/qmake/generators/win32/msvc_objectmodel.h @@ -52,7 +52,8 @@ enum DotNET { NET2012 = 0xb0, NET2013 = 0xc0, NET2015 = 0xd0, - NET2017 = 0xe0 + NET2017 = 0xe0, + NET2019 }; DotNET vsVersionFromString(const ProString &versionString); diff --git a/qmake/generators/win32/msvc_vcproj.cpp b/qmake/generators/win32/msvc_vcproj.cpp index a81e540e1f..669c8287ff 100644 --- a/qmake/generators/win32/msvc_vcproj.cpp +++ b/qmake/generators/win32/msvc_vcproj.cpp @@ -74,6 +74,8 @@ const char _slnHeader140[] = "Microsoft Visual Studio Solution File, Format "\n# Visual Studio 2015"; const char _slnHeader141[] = "Microsoft Visual Studio Solution File, Format Version 12.00" "\n# Visual Studio 2017"; +const char _slnHeader142[] = "Microsoft Visual Studio Solution File, Format Version 12.00" + "\n# Visual Studio Version 16"; // The following UUID _may_ change for later servicepacks... // If so we need to search through the registry at // HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\7.0\Projects @@ -301,6 +303,8 @@ QString VcprojGenerator::retrievePlatformToolSet() const return QStringLiteral("v140"); case NET2017: return QStringLiteral("v141"); + case NET2019: + return QStringLiteral("v142"); default: return QString(); } @@ -527,6 +531,9 @@ void VcprojGenerator::writeSubDirs(QTextStream &t) } switch (vcProject.Configuration.CompilerVersion) { + case NET2019: + t << _slnHeader142; + break; case NET2017: t << _slnHeader141; break; @@ -874,6 +881,9 @@ void VcprojGenerator::initProject() // Own elements ----------------------------- vcProject.Name = project->first("QMAKE_ORIG_TARGET").toQString(); switch (vcProject.Configuration.CompilerVersion) { + case NET2019: + vcProject.Version = "16.00"; + break; case NET2017: vcProject.Version = "15.00"; break; -- cgit v1.2.3 From 083c03e22b40cda682043df1044e01e15df2ce4b Mon Sep 17 00:00:00 2001 From: Oliver Wolff Date: Tue, 12 Feb 2019 10:37:10 +0100 Subject: qmake vcxproj generator: Use correct version in solution header for 2017 Change-Id: I360202c88a8da84f3ecaf43304fcf6f5a992b953 Reviewed-by: Joerg Bornemann --- qmake/generators/win32/msvc_vcproj.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'qmake/generators/win32') diff --git a/qmake/generators/win32/msvc_vcproj.cpp b/qmake/generators/win32/msvc_vcproj.cpp index 669c8287ff..713a55d16b 100644 --- a/qmake/generators/win32/msvc_vcproj.cpp +++ b/qmake/generators/win32/msvc_vcproj.cpp @@ -73,7 +73,7 @@ const char _slnHeader120[] = "Microsoft Visual Studio Solution File, Format const char _slnHeader140[] = "Microsoft Visual Studio Solution File, Format Version 12.00" "\n# Visual Studio 2015"; const char _slnHeader141[] = "Microsoft Visual Studio Solution File, Format Version 12.00" - "\n# Visual Studio 2017"; + "\n# Visual Studio 15"; const char _slnHeader142[] = "Microsoft Visual Studio Solution File, Format Version 12.00" "\n# Visual Studio Version 16"; // The following UUID _may_ change for later servicepacks... -- cgit v1.2.3 From 1136c9849e26423f72d7a0a7a92be8c93c13d7a6 Mon Sep 17 00:00:00 2001 From: Oliver Wolff Date: Thu, 21 Feb 2019 09:58:29 +0100 Subject: qmake: vcproj: Fix windeployqt config for dll targets Instead of hardcoding the target's extension to ".exe" we should rely on target information available in Visual Studio. $(TargetFileName) is documented as "The file name of the primary output file for the build (defined as base name + file extension)." so it can be used instead of $(TargetName) together with ".exe". Change-Id: I103d8d13456910617b2d53c9c8f4e2935eb93015 Reviewed-by: Kai Koehne --- qmake/generators/win32/msvc_vcproj.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'qmake/generators/win32') diff --git a/qmake/generators/win32/msvc_vcproj.cpp b/qmake/generators/win32/msvc_vcproj.cpp index 713a55d16b..f83e5c0247 100644 --- a/qmake/generators/win32/msvc_vcproj.cpp +++ b/qmake/generators/win32/msvc_vcproj.cpp @@ -1350,7 +1350,7 @@ void VcprojGenerator::initWinDeployQtTool() // structure manually by invoking windeployqt a second time, so that // the MDILXapCompile call succeeds and deployment continues. conf.windeployqt.CommandLine += commandLine - + QStringLiteral(" -list relative -dir \"$(MSBuildProjectDirectory)\" \"$(OutDir)\\$(TargetName).exe\" > ") + + QStringLiteral(" -list relative -dir \"$(MSBuildProjectDirectory)\" \"$(OutDir)\\$(TargetFileName)\" > ") + MakefileGenerator::shellQuote(conf.windeployqt.Record); conf.windeployqt.config = &vcProject.Configuration; conf.windeployqt.ExcludedFromBuild = false; -- cgit v1.2.3 From 8f507a0b02e96072a7e2a9dda2d34efd85163926 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Mon, 25 Feb 2019 14:56:53 +0100 Subject: Display EXTRA_TRANSLATIONS files in VS projects This amends commit 01d2f35b. Change-Id: I958c924f7f5a477f5ebced895ce2678d282526ad Reviewed-by: Kai Koehne --- qmake/generators/win32/msvc_vcproj.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'qmake/generators/win32') diff --git a/qmake/generators/win32/msvc_vcproj.cpp b/qmake/generators/win32/msvc_vcproj.cpp index f83e5c0247..e8340164ad 100644 --- a/qmake/generators/win32/msvc_vcproj.cpp +++ b/qmake/generators/win32/msvc_vcproj.cpp @@ -1447,6 +1447,7 @@ void VcprojGenerator::initTranslationFiles() vcProject.TranslationFiles.Guid = _GUIDTranslationFiles; vcProject.TranslationFiles.addFiles(project->values("TRANSLATIONS")); + vcProject.TranslationFiles.addFiles(project->values("EXTRA_TRANSLATIONS")); vcProject.TranslationFiles.Project = this; vcProject.TranslationFiles.Config = &(vcProject.Configuration); -- cgit v1.2.3 From b0dcb94d9462f38e36c15ddec64e5eb0a04630a4 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Mon, 25 Feb 2019 14:58:28 +0100 Subject: vcxproj generator: Fix files being in multiple filters Visual Studio doesn't support files being in multiple filters and refuses to load such projects. Source files that appear in variables that are mapped to file filters (SOURCES, TRANSLATIONS, ...) must not be added to a second filter if they are input for an extra compiler. Fixes: QTBUG-74004 Change-Id: Id2d752059c98d04e8154a7848c91f29a94bd092a Reviewed-by: Kai Koehne --- qmake/generators/win32/msvc_vcproj.cpp | 26 ++++++++++++++++++++++++-- qmake/generators/win32/msvc_vcproj.h | 1 + 2 files changed, 25 insertions(+), 2 deletions(-) (limited to 'qmake/generators/win32') diff --git a/qmake/generators/win32/msvc_vcproj.cpp b/qmake/generators/win32/msvc_vcproj.cpp index e8340164ad..be0b67a9e6 100644 --- a/qmake/generators/win32/msvc_vcproj.cpp +++ b/qmake/generators/win32/msvc_vcproj.cpp @@ -1570,7 +1570,7 @@ void VcprojGenerator::initExtraCompilerOutputs() const ProStringList &tmp_in = project->values(project->first(ProKey(*it + ".input")).toKey()); for (int i = 0; i < tmp_in.count(); ++i) { const QString &filename = tmp_in.at(i).toQString(); - if (extraCompilerSources.contains(filename)) + if (extraCompilerSources.contains(filename) && !otherFiltersContain(filename)) extraCompile.addFile(Option::fixPathToTargetOS( replaceExtraCompilerVariables(filename, tmp_out, QString(), NoShell), false)); } @@ -1586,7 +1586,7 @@ void VcprojGenerator::initExtraCompilerOutputs() const ProStringList &tmp_in = project->values(inputVar.toKey()); for (int i = 0; i < tmp_in.count(); ++i) { const QString &filename = tmp_in.at(i).toQString(); - if (extraCompilerSources.contains(filename)) + if (extraCompilerSources.contains(filename) && !otherFiltersContain(filename)) extraCompile.addFile(Option::fixPathToTargetOS( replaceExtraCompilerVariables(filename, QString(), QString(), NoShell), false)); } @@ -1600,6 +1600,28 @@ void VcprojGenerator::initExtraCompilerOutputs() } } +bool VcprojGenerator::otherFiltersContain(const QString &fileName) const +{ + auto filterFileMatches = [&fileName] (const VCFilterFile &ff) + { + return ff.file == fileName; + }; + for (const VCFilter *filter : { &vcProject.RootFiles, + &vcProject.SourceFiles, + &vcProject.HeaderFiles, + &vcProject.GeneratedFiles, + &vcProject.LexYaccFiles, + &vcProject.TranslationFiles, + &vcProject.FormFiles, + &vcProject.ResourceFiles, + &vcProject.DeploymentFiles, + &vcProject.DistributionFiles}) { + if (std::any_of(filter->Files.cbegin(), filter->Files.cend(), filterFileMatches)) + return true; + } + return false; +} + // ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------ diff --git a/qmake/generators/win32/msvc_vcproj.h b/qmake/generators/win32/msvc_vcproj.h index 6af5ec7007..0b9770e962 100644 --- a/qmake/generators/win32/msvc_vcproj.h +++ b/qmake/generators/win32/msvc_vcproj.h @@ -131,6 +131,7 @@ private: ProString firstInputFileName(const ProString &extraCompilerName) const; QString firstExpandedOutputFileName(const ProString &extraCompilerName); void createCustomBuildToolFakeFile(const QString &cbtFilePath, const QString &realOutFilePath); + bool otherFiltersContain(const QString &fileName) const; friend class VCFilter; }; -- cgit v1.2.3 From cc7444eb65fc42f00a33275f6b8d1d3d39f4d715 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Thu, 28 Feb 2019 10:02:21 +0100 Subject: Fix library search path order on Windows Commit 2327944d added the QMAKE_DEFAULT_LIBDIRS to the library search paths without taking care that explicit library search paths should be inserted before system search paths. Copy the behavior of the UnixMakefileGenerator, esp. of commits 5bc9541e and e185f343. Fixes: QTBUG-73959 Change-Id: I7e951f432bb5f71ce4bcdb18b7102b4380441181 Reviewed-by: Oswald Buddenhagen --- qmake/generators/win32/winmakefile.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'qmake/generators/win32') diff --git a/qmake/generators/win32/winmakefile.cpp b/qmake/generators/win32/winmakefile.cpp index 6046e5791e..208af1327f 100644 --- a/qmake/generators/win32/winmakefile.cpp +++ b/qmake/generators/win32/winmakefile.cpp @@ -84,6 +84,7 @@ Win32MakefileGenerator::findLibraries(bool linkPrl, bool mergeLflags) if (impexts.isEmpty()) impexts = project->values("QMAKE_EXTENSION_STATICLIB"); QList dirs; + int libidx = 0; for (const ProString &dlib : project->values("QMAKE_DEFAULT_LIBDIRS")) dirs.append(QMakeLocalFileName(dlib.toQString())); static const char * const lflags[] = { "LIBS", "LIBS_PRIVATE", @@ -96,11 +97,12 @@ Win32MakefileGenerator::findLibraries(bool linkPrl, bool mergeLflags) LibFlagType type = parseLibFlag(opt, &arg); if (type == LibFlagPath) { QMakeLocalFileName lp(arg.toQString()); - if (dirs.contains(lp)) { + int idx = dirs.indexOf(lp); + if (idx >= 0 && idx < libidx) { it = l.erase(it); continue; } - dirs.append(lp); + dirs.insert(libidx++, lp); (*it) = "-L" + lp.real(); } else if (type == LibFlagLib) { QString lib = arg.toQString(); -- cgit v1.2.3 From 0ba8ed2c5faaebd0236a8e0dcf8964341ee56ce4 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Tue, 12 Mar 2019 11:58:28 +0100 Subject: Add .lib and .exp files to clean targets only for libraries There is no point in adding those to applications. Change-Id: Ic8d3009b5099c266f56b5bdaa831d0816510bc3b Reviewed-by: Oliver Wolff --- qmake/generators/win32/msvc_nmake.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'qmake/generators/win32') diff --git a/qmake/generators/win32/msvc_nmake.cpp b/qmake/generators/win32/msvc_nmake.cpp index a6e850a036..650c0888c7 100644 --- a/qmake/generators/win32/msvc_nmake.cpp +++ b/qmake/generators/win32/msvc_nmake.cpp @@ -254,7 +254,7 @@ void NmakeMakefileGenerator::init() ProString tgt = project->first("DESTDIR") + project->first("TARGET") + project->first("TARGET_VERSION_EXT"); - if(project->isActiveConfig("shared")) { + if (project->first("TEMPLATE") == "lib" && project->isActiveConfig("shared")) { project->values("QMAKE_CLEAN").append(tgt + ".exp"); project->values("QMAKE_DISTCLEAN").append(tgt + ".lib"); } -- cgit v1.2.3 From 9e97d64ccd27adcb2053c90cfbcafaef68e53893 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Tue, 12 Mar 2019 11:59:58 +0100 Subject: Fix installation of .pdb files for applications that have VERSION set For applications that set VERSION the installation targets of pdb files were wrong in qmake's nmake Makefile generator. Replace code that tries to reconstruct that target's versioned extension with TARGET_EXT which already contains the fully resolved target extension. Fixes: QTBUG-74265 Change-Id: I9553a5f70170e077a59c866079ae51647ae80bef Reviewed-by: Oliver Wolff --- qmake/generators/win32/msvc_nmake.cpp | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'qmake/generators/win32') diff --git a/qmake/generators/win32/msvc_nmake.cpp b/qmake/generators/win32/msvc_nmake.cpp index 650c0888c7..f295705e2e 100644 --- a/qmake/generators/win32/msvc_nmake.cpp +++ b/qmake/generators/win32/msvc_nmake.cpp @@ -95,7 +95,9 @@ QString NmakeMakefileGenerator::defaultInstall(const QString &t) if (project->isActiveConfig("debug_info")) { if (t == "dlltarget" || project->values(ProKey(t + ".CONFIG")).indexOf("no_dll") == -1) { - QString pdb_target = project->first("TARGET") + project->first("TARGET_VERSION_EXT") + ".pdb"; + const QFileInfo targetFileInfo = project->first("DESTDIR") + project->first("TARGET") + + project->first("TARGET_EXT"); + const QString pdb_target = targetFileInfo.completeBaseName() + ".pdb"; QString src_targ = (project->isEmpty("DESTDIR") ? QString("$(DESTDIR)") : project->first("DESTDIR")) + pdb_target; QString dst_targ = filePrefixRoot(root, fileFixify(targetdir + pdb_target, FileFixifyAbsolute)); if(!ret.isEmpty()) @@ -252,15 +254,16 @@ void NmakeMakefileGenerator::init() project->values("PRECOMPILED_PCH_C") = ProStringList(precompPchC); } - ProString tgt = project->first("DESTDIR") - + project->first("TARGET") + project->first("TARGET_VERSION_EXT"); + const QFileInfo targetFileInfo = project->first("DESTDIR") + project->first("TARGET") + + project->first("TARGET_EXT"); + const ProString targetBase = targetFileInfo.path() + '/' + targetFileInfo.completeBaseName(); if (project->first("TEMPLATE") == "lib" && project->isActiveConfig("shared")) { - project->values("QMAKE_CLEAN").append(tgt + ".exp"); - project->values("QMAKE_DISTCLEAN").append(tgt + ".lib"); + project->values("QMAKE_CLEAN").append(targetBase + ".exp"); + project->values("QMAKE_DISTCLEAN").append(targetBase + ".lib"); } if (project->isActiveConfig("debug_info")) { QString pdbfile; - QString distPdbFile = tgt + ".pdb"; + QString distPdbFile = targetBase + ".pdb"; if (project->isActiveConfig("staticlib")) { // For static libraries, the compiler's pdb file and the dist pdb file are the same. pdbfile = distPdbFile; @@ -276,8 +279,8 @@ void NmakeMakefileGenerator::init() project->values("QMAKE_DISTCLEAN").append(distPdbFile); } if (project->isActiveConfig("debug")) { - project->values("QMAKE_CLEAN").append(tgt + ".ilk"); - project->values("QMAKE_CLEAN").append(tgt + ".idb"); + project->values("QMAKE_CLEAN").append(targetBase + ".ilk"); + project->values("QMAKE_CLEAN").append(targetBase + ".idb"); } else { ProStringList &defines = project->values("DEFINES"); if (!defines.contains("NDEBUG")) -- cgit v1.2.3 From 8cd0a39dd79a48697c181c3754cada4ffd832214 Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Fri, 5 Apr 2019 09:53:22 +0200 Subject: qmake: Remove special-handling of cl.exe's -Gm option The comment hints that it's fixing an issue in Visual Studio 2013, which we don't support anymore. In all supported Visual Studio Versions -Gm is actually deprecated anyhow, and not set anymore by default. So I guess it's safe to remove the special handling here. Change-Id: I2e8ff85350ba651d9a763aabba7b6494ba88d82e Reviewed-by: Joerg Bornemann --- qmake/generators/win32/msvc_nmake.cpp | 8 -------- qmake/generators/win32/msvc_vcproj.cpp | 10 ---------- 2 files changed, 18 deletions(-) (limited to 'qmake/generators/win32') diff --git a/qmake/generators/win32/msvc_nmake.cpp b/qmake/generators/win32/msvc_nmake.cpp index f295705e2e..af6d3c5aff 100644 --- a/qmake/generators/win32/msvc_nmake.cpp +++ b/qmake/generators/win32/msvc_nmake.cpp @@ -171,15 +171,7 @@ QString NmakeMakefileGenerator::var(const ProKey &value) const .arg(precompH_f, precompH_f, escapeFilePath(isRunC ? precompPchC : precompPch)); QString p = MakefileGenerator::var(value); p.replace(QLatin1String("-c"), precompRule); - // Cannot use -Gm with -FI & -Yu, as this gives an - // internal compiler error, on the newer compilers - // ### work-around for a VS 2003 bug. Move to some prf file or remove completely. - p.remove("-Gm"); return p; - } else if (value == "QMAKE_CXXFLAGS") { - // Remove internal compiler error option - // ### work-around for a VS 2003 bug. Move to some prf file or remove completely. - return MakefileGenerator::var(value).remove("-Gm"); } } diff --git a/qmake/generators/win32/msvc_vcproj.cpp b/qmake/generators/win32/msvc_vcproj.cpp index 06a96f7538..fd53ec2a6e 100644 --- a/qmake/generators/win32/msvc_vcproj.cpp +++ b/qmake/generators/win32/msvc_vcproj.cpp @@ -1063,16 +1063,6 @@ void VcprojGenerator::initCompilerTool() conf.compiler.PrecompiledHeaderFile = "$(IntDir)\\" + precompPch; conf.compiler.PrecompiledHeaderThrough = project->first("PRECOMPILED_HEADER").toQString(); conf.compiler.ForcedIncludeFiles = project->values("PRECOMPILED_HEADER").toQStringList(); - - if (conf.CompilerVersion <= NET2003) { - // Minimal build option triggers an Internal Compiler Error - // when used in conjunction with /FI and /Yu, so remove it - // ### work-around for a VS 2003 bug. Move to some prf file or remove completely. - project->values("QMAKE_CFLAGS_DEBUG").removeAll("-Gm"); - project->values("QMAKE_CFLAGS_DEBUG").removeAll("/Gm"); - project->values("QMAKE_CXXFLAGS_DEBUG").removeAll("-Gm"); - project->values("QMAKE_CXXFLAGS_DEBUG").removeAll("/Gm"); - } } conf.compiler.parseOptions(project->values("QMAKE_CXXFLAGS")); -- cgit v1.2.3 From eaf20420f8a4d72c804a9d3725c3e294b34c78c8 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Wed, 3 Apr 2019 12:59:51 +0200 Subject: Fix precompiled headers with clang-cl MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Clang-cl couldn't find the header given to it by -FI when it isn't in any of the included directories. Additionally clang-cl 8 has a bug with exported templated classes with inline methods that causes it to have missing symbols at link time. We work around this. Fixes: QTBUG-74563 Change-Id: I7becf05fa8edb07bd4cefe12bee3737e5e1dfa14 Reviewed-by: Yuhang Zhao <2546789017@qq.com> Reviewed-by: MÃ¥rten Nordheim Reviewed-by: Kai Koehne --- qmake/generators/win32/msvc_nmake.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'qmake/generators/win32') diff --git a/qmake/generators/win32/msvc_nmake.cpp b/qmake/generators/win32/msvc_nmake.cpp index af6d3c5aff..63d89a5388 100644 --- a/qmake/generators/win32/msvc_nmake.cpp +++ b/qmake/generators/win32/msvc_nmake.cpp @@ -165,10 +165,14 @@ QString NmakeMakefileGenerator::var(const ProKey &value) const || value == "QMAKE_RUN_CXX_IMP" || value == "QMAKE_RUN_CXX"); if ((isRunCpp && usePCH) || (isRunC && usePCHC)) { - QFileInfo precompHInfo(fileInfo(precompH)); - QString precompH_f = escapeFilePath(precompHInfo.fileName()); + QString precompH_f = escapeFilePath(fileFixify(precompH, FileFixifyBackwards)); QString precompRule = QString("-c -FI%1 -Yu%2 -Fp%3") .arg(precompH_f, precompH_f, escapeFilePath(isRunC ? precompPchC : precompPch)); + // ### For clang_cl 8 we force inline methods to be compiled here instead + // linking them from a pch.o file. We do this by pretending we are also doing + // the pch.o generation step. + if (project->isActiveConfig("clang_cl")) + precompRule += QString(" -Xclang -building-pch-with-obj"); QString p = MakefileGenerator::var(value); p.replace(QLatin1String("-c"), precompRule); return p; @@ -230,7 +234,10 @@ void NmakeMakefileGenerator::init() precompObj = var("PRECOMPILED_DIR") + project->first("TARGET") + "_pch" + Option::obj_ext; precompPch = var("PRECOMPILED_DIR") + project->first("TARGET") + "_pch.pch"; // Add linking of precompObj (required for whole precompiled classes) - project->values("OBJECTS") += precompObj; + // ### For clang_cl we currently let inline methods be generated in the normal objects, + // since the PCH object is buggy (as of clang 8.0.0) + if (!project->isActiveConfig("clang_cl")) + project->values("OBJECTS") += precompObj; // Add pch file to cleanup project->values("QMAKE_CLEAN") += precompPch; // Return to variable pool @@ -240,7 +247,8 @@ void NmakeMakefileGenerator::init() if (usePCHC) { precompObjC = var("PRECOMPILED_DIR") + project->first("TARGET") + "_pch_c" + Option::obj_ext; precompPchC = var("PRECOMPILED_DIR") + project->first("TARGET") + "_pch_c.pch"; - project->values("OBJECTS") += precompObjC; + if (!project->isActiveConfig("clang_cl")) + project->values("OBJECTS") += precompObjC; project->values("QMAKE_CLEAN") += precompPchC; project->values("PRECOMPILED_OBJECT_C") = ProStringList(precompObjC); project->values("PRECOMPILED_PCH_C") = ProStringList(precompPchC); -- cgit v1.2.3