VS: Generate a custom command only in the least dependent target

If a custom command is assigned to multiple targets, generate the build
rule only in the least-dependent `.vcxproj` file.  Otherwise MSBuild
will run the command on the first build of a dependent target even if
its dependencies already brought the command up to date (in order to
populates its build log).

Generate targets in least-to-most-dependent order, and assign a custom
command to the least dependent target.

Added cmLocalVisualStudio10Generator::GenerateTargetsDepthFirst to call
cmVisualStudio10TargetGenerator::Generate in least-dependent order.

Moved SourcesVisited from cmVisualStudio10TargetGenerator to
cmLocalVisualStudio10Generator to avoid attaching a custom command to
multiple targets among the local generator.

Fixes: #16767
This commit is contained in:
Fujii Hironori
2018-03-23 15:44:42 +09:00
parent d58d4daa6b
commit f59c33a763
8 changed files with 82 additions and 16 deletions
-1
View File
@@ -209,7 +209,6 @@ private:
cmGlobalVisualStudio10Generator* const GlobalGenerator;
cmGeneratedFileStream* BuildFileStream;
cmLocalVisualStudio10Generator* const LocalGenerator;
std::set<cmSourceFile const*> SourcesVisited;
std::set<std::string> CSharpCustomCommandNames;
bool IsMissingFiles;
std::vector<std::string> AddedFiles;