From 8cef809b16aac9d4c4163ff2e2e831adf70133c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Tue, 2 Jan 2018 22:49:08 +0200 Subject: qmake: Handle QMAKE_LINK_OBJECT_MAX being unset for static libraries This was missed in 8bebded9. Task-number: QTBUG-63637 Change-Id: I6be472430a9aa8f533def4fd6c14c8dbfe8b6f70 Reviewed-by: Oswald Buddenhagen --- qmake/generators/win32/mingw_make.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'qmake/generators/win32') diff --git a/qmake/generators/win32/mingw_make.cpp b/qmake/generators/win32/mingw_make.cpp index 792ffb1997..d6d6b04148 100644 --- a/qmake/generators/win32/mingw_make.cpp +++ b/qmake/generators/win32/mingw_make.cpp @@ -324,7 +324,8 @@ void MingwMakefileGenerator::writeBuildRulesPart(QTextStream &t) t << "\n\t" <isActiveConfig("staticlib") && project->first("TEMPLATE") == "lib") { t << "\n\t-$(DEL_FILE) $(DESTDIR_TARGET) 2>" << var("QMAKE_SHELL_NULL_DEVICE"); - if (project->values("OBJECTS").count() < var("QMAKE_LINK_OBJECT_MAX").toInt()) { + const ProString &objmax = project->first("QMAKE_LINK_OBJECT_MAX"); + if (objmax.isEmpty() || project->values("OBJECTS").count() < objmax.toInt()) { t << "\n\t$(LIB) $(DESTDIR_TARGET) " << objectsLinkLine << " " ; } else { t << "\n\t" << objectsLinkLine << " " ; -- cgit v1.2.3 From af1a179cc8b599523ca858b1b9f55c93a734d047 Mon Sep 17 00:00:00 2001 From: Orgad Shaneh Date: Tue, 2 Jan 2018 19:07:03 +0200 Subject: qmake: Introduce precompile_header_c for MSVC MSVC requires that the C PCH file is compiled (as an object) and linked if any C file is found, and the same for C++. Most qmake projects are C++. If a C++ project has a precompiled header, it is typically of C++ type, and cannot be compiled as C (for example, it contains or includes classes). Since there is no easy way to conditionally build the C PCH file only if C files are found in the project (as done for g++), we need a setting that is disabled by default. This amends 30331afda118. [ChangeLog][Tools][qmake] Introduced precompile_header_c CONFIG option for MSVC to enable precompiled header for C sources. Task-number: QTBUG-65103 Change-Id: Id9688a35ee7d9b5e4f5a846b81986cb674bc5f4e Reviewed-by: Oswald Buddenhagen --- qmake/generators/win32/msvc_nmake.cpp | 29 +++++++++++++++++------------ qmake/generators/win32/msvc_nmake.h | 2 +- 2 files changed, 18 insertions(+), 13 deletions(-) (limited to 'qmake/generators/win32') diff --git a/qmake/generators/win32/msvc_nmake.cpp b/qmake/generators/win32/msvc_nmake.cpp index b4c2579c5c..ccc2ea6d2b 100644 --- a/qmake/generators/win32/msvc_nmake.cpp +++ b/qmake/generators/win32/msvc_nmake.cpp @@ -51,7 +51,7 @@ static QString nmakePathList(const QStringList &list) .replace('#', QLatin1String("^#")).replace('$', QLatin1String("$$")); } -NmakeMakefileGenerator::NmakeMakefileGenerator() : Win32MakefileGenerator(), usePCH(false) +NmakeMakefileGenerator::NmakeMakefileGenerator() : usePCH(false), usePCHC(false) { } @@ -324,6 +324,8 @@ void NmakeMakefileGenerator::writeNmakeParts(QTextStream &t) << escapeDependencyPaths(findDependencies(precompH)).join(" \\\n\t\t") << "\n\t$(CXX) " + precompRule +" $(CXXFLAGS) $(INCPATH) -TP " << escapeFilePath(precompH) << endl << endl; + } + if (usePCHC) { QString precompRuleC = QString("-c -Yc -Fp%1 -Fo%2") .arg(escapeFilePath(precompPchC), escapeFilePath(precompObjC)); t << escapeDependencyPath(precompObjC) << ": " << escapeDependencyPath(precompH) << ' ' @@ -335,14 +337,14 @@ void NmakeMakefileGenerator::writeNmakeParts(QTextStream &t) QString NmakeMakefileGenerator::var(const ProKey &value) const { - if (usePCH) { + if (usePCH || usePCHC) { const bool isRunC = (value == "QMAKE_RUN_CC_IMP_BATCH" || value == "QMAKE_RUN_CC_IMP" || value == "QMAKE_RUN_CC"); - if (isRunC - || value == "QMAKE_RUN_CXX_IMP_BATCH" - || value == "QMAKE_RUN_CXX_IMP" - || value == "QMAKE_RUN_CXX") { + const bool isRunCpp = (value == "QMAKE_RUN_CXX_IMP_BATCH" + || 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 precompRule = QString("-c -FI%1 -Yu%2 -Fp%3") @@ -410,21 +412,24 @@ void NmakeMakefileGenerator::init() // Setup PCH variables precompH = project->first("PRECOMPILED_HEADER").toQString(); usePCH = !precompH.isEmpty() && project->isActiveConfig("precompile_header"); + usePCHC = !precompH.isEmpty() && project->isActiveConfig("precompile_header_c"); if (usePCH) { // Created files precompObj = var("PRECOMPILED_DIR") + project->first("TARGET") + "_pch" + Option::obj_ext; precompPch = var("PRECOMPILED_DIR") + project->first("TARGET") + "_pch.pch"; - precompObjC = var("PRECOMPILED_DIR") + project->first("TARGET") + "_pch_c" + Option::obj_ext; - precompPchC = var("PRECOMPILED_DIR") + project->first("TARGET") + "_pch_c.pch"; // Add linking of precompObj (required for whole precompiled classes) - project->values("OBJECTS") += precompObj; - project->values("OBJECTS") += precompObjC; + project->values("OBJECTS") += precompObj; // Add pch file to cleanup - project->values("QMAKE_CLEAN") += precompPch; - project->values("QMAKE_CLEAN") += precompPchC; + project->values("QMAKE_CLEAN") += precompPch; // Return to variable pool project->values("PRECOMPILED_OBJECT") = ProStringList(precompObj); project->values("PRECOMPILED_PCH") = ProStringList(precompPch); + } + 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; + project->values("QMAKE_CLEAN") += precompPchC; project->values("PRECOMPILED_OBJECT_C") = ProStringList(precompObjC); project->values("PRECOMPILED_PCH_C") = ProStringList(precompPchC); } diff --git a/qmake/generators/win32/msvc_nmake.h b/qmake/generators/win32/msvc_nmake.h index 4b0935bb66..67b609d0a6 100644 --- a/qmake/generators/win32/msvc_nmake.h +++ b/qmake/generators/win32/msvc_nmake.h @@ -53,7 +53,7 @@ protected: QString var(const ProKey &value) const; QString precompH, precompObj, precompPch; QString precompObjC, precompPchC; - bool usePCH; + bool usePCH, usePCHC; public: NmakeMakefileGenerator(); -- cgit v1.2.3