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>
This commit is contained in:
parent
8f507a0b02
commit
b0dcb94d94
@ -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;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
|
||||
|
@ -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;
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user