Browse Source

VS: Avoid unnecessary duplication of custom commands across targets in VS 9

Do not attach a custom command to a target if it is already attached to one of
the target's dependencies.  The command's output will be available by the time
the target needs it because the dependency containing the command will have
already been built.

The same change was already made by commit f59c33a763 (VS: Generate a
custom command only in the least dependent target, 2018-03-23,
v3.12.0-rc1~171^2) for VS 10+.
Brad King 5 years ago
parent
commit
066f4d0f0a
1 changed files with 6 additions and 1 deletions
  1. 6 1
      Source/cmLocalVisualStudio7Generator.cxx

+ 6 - 1
Source/cmLocalVisualStudio7Generator.cxx

@@ -1624,6 +1624,8 @@ bool cmLocalVisualStudio7Generator::WriteGroup(
     this->WriteVCProjBeginGroup(fout, name.c_str(), "");
   }
 
+  auto& sourcesVisited = this->GetSourcesVisited(target);
+
   // Loop through each source in the source group.
   for (const cmSourceFile* sf : sourceFiles) {
     std::string source = sf->GetFullPath();
@@ -1647,7 +1649,10 @@ bool cmLocalVisualStudio7Generator::WriteGroup(
       // build it, then it will.
       fout << "\t\t\t\tRelativePath=\"" << d << "\">\n";
       if (cmCustomCommand const* command = sf->GetCustomCommand()) {
-        this->WriteCustomRule(fout, configs, source.c_str(), *command, fcinfo);
+        if (sourcesVisited.insert(sf).second) {
+          this->WriteCustomRule(fout, configs, source.c_str(), *command,
+                                fcinfo);
+        }
       } else if (!fcinfo.FileConfigMap.empty()) {
         const char* aCompilerTool = "VCCLCompilerTool";
         std::string ppLang = "CXX";