summaryrefslogtreecommitdiffstats
path: root/qmake/generators/win32/msvc_vcproj.cpp
diff options
context:
space:
mode:
authorJoerg Bornemann <joerg.bornemann@qt.io>2019-02-25 14:58:28 +0100
committerJoerg Bornemann <joerg.bornemann@qt.io>2019-02-26 07:30:53 +0000
commitb0dcb94d9462f38e36c15ddec64e5eb0a04630a4 (patch)
tree262015e061aed6b3f33ef0f57a89d5409a18425c /qmake/generators/win32/msvc_vcproj.cpp
parent8f507a0b02e96072a7e2a9dda2d34efd85163926 (diff)
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 <kai.koehne@qt.io>
Diffstat (limited to 'qmake/generators/win32/msvc_vcproj.cpp')
-rw-r--r--qmake/generators/win32/msvc_vcproj.cpp26
1 files changed, 24 insertions, 2 deletions
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;
+}
+
// ------------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------------