From 066f4d0f0a324f0db810cde38904996bb16592cb Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 3 Sep 2020 15:44:07 -0400 Subject: 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+. --- Source/cmLocalVisualStudio7Generator.cxx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index 362c3e7..7795654 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/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"; -- cgit v0.12