summaryrefslogtreecommitdiffstats
path: root/qmake/generators/metamakefile.cpp
diff options
context:
space:
mode:
authorAlexandru Croitor <alexandru.croitor@qt.io>2019-10-11 16:16:29 +0200
committerAlexandru Croitor <alexandru.croitor@qt.io>2019-10-11 16:23:19 +0200
commitf4b4c4f79b629498f3cddbbc10df8c1b4d6020d9 (patch)
tree4119707660438ff58bd51f9cbe0f9e2a33f4b806 /qmake/generators/metamakefile.cpp
parent9bd6cec74dbbc5aece55dc0c8808494db29b9963 (diff)
parent93f2f33a49f6c96a4f94f344edf03164ed944d02 (diff)
Merge remote-tracking branch 'origin/wip/qt6' into wip/cmake
Diffstat (limited to 'qmake/generators/metamakefile.cpp')
-rw-r--r--qmake/generators/metamakefile.cpp39
1 files changed, 39 insertions, 0 deletions
diff --git a/qmake/generators/metamakefile.cpp b/qmake/generators/metamakefile.cpp
index 705ad7008a..22a72100f7 100644
--- a/qmake/generators/metamakefile.cpp
+++ b/qmake/generators/metamakefile.cpp
@@ -33,6 +33,10 @@
#include "project.h"
#include "cachekeys.h"
+#include <algorithm>
+#include <iterator>
+#include <utility>
+
#define BUILDSMETATYPE 1
#define SUBDIRSMETATYPE 2
@@ -58,6 +62,7 @@ private:
void clearBuilds();
MakefileGenerator *processBuild(const ProString &);
void accumulateVariableFromBuilds(const ProKey &name, Build *build) const;
+ void checkForConflictingTargets() const;
public:
@@ -186,6 +191,7 @@ BuildsMetaMakefileGenerator::write()
if(!build->makefile) {
ret = false;
} else if(build == glue) {
+ checkForConflictingTargets();
accumulateVariableFromBuilds("QMAKE_INTERNAL_INCLUDED_FILES", build);
ret = build->makefile->writeProjectMakefile();
} else {
@@ -239,6 +245,39 @@ void BuildsMetaMakefileGenerator::accumulateVariableFromBuilds(const ProKey &nam
values.removeDuplicates();
}
+void BuildsMetaMakefileGenerator::checkForConflictingTargets() const
+{
+ if (makefiles.count() < 3) {
+ // Checking for conflicts only makes sense if we have more than one BUILD,
+ // and the last entry in makefiles is the "glue" Build.
+ return;
+ }
+ using TargetInfo = std::pair<Build *, ProString>;
+ QVector<TargetInfo> targets;
+ const int last = makefiles.count() - 1;
+ targets.resize(last);
+ for (int i = 0; i < last; ++i) {
+ Build *b = makefiles.at(i);
+ auto mkf = b->makefile;
+ auto prj = mkf->projectFile();
+ targets[i] = std::make_pair(b, prj->first(mkf->fullTargetVariable()));
+ }
+ std::stable_sort(targets.begin(), targets.end(),
+ [](const TargetInfo &lhs, const TargetInfo &rhs)
+ {
+ return lhs.second < rhs.second;
+ });
+ for (auto prev = targets.begin(), it = std::next(prev); it != targets.end(); ++prev, ++it) {
+ if (prev->second == it->second) {
+ warn_msg(WarnLogic, "Targets of builds '%s' and '%s' conflict: %s.",
+ qPrintable(prev->first->build),
+ qPrintable(it->first->build),
+ qPrintable(prev->second.toQString()));
+ break;
+ }
+ }
+}
+
class SubdirsMetaMakefileGenerator : public MetaMakefileGenerator
{
protected: