From eccb39d7f44f97d395b75b985b4e18178b72df8c Mon Sep 17 00:00:00 2001 From: Brad King Date: Tue, 6 Aug 2013 10:17:37 -0400 Subject: [PATCH] VS 6,7: Refactor local generators to avoid GetSourceFileWithOutput Use the cmSourceFile returned by AddCustomCommandToOutput instead of throwing out the return value and looking it up with GetSourceFileWithOutput. --- Source/cmLocalVisualStudio6Generator.cxx | 18 ++++++++---------- Source/cmLocalVisualStudio7Generator.cxx | 7 +++---- 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/Source/cmLocalVisualStudio6Generator.cxx b/Source/cmLocalVisualStudio6Generator.cxx index 667d86f4c..e5b4057d2 100644 --- a/Source/cmLocalVisualStudio6Generator.cxx +++ b/Source/cmLocalVisualStudio6Generator.cxx @@ -573,22 +573,20 @@ cmLocalVisualStudio6Generator // Add the rule with the given dependencies and commands. const char* no_main_dependency = 0; - this->Makefile->AddCustomCommandToOutput(output, - depends, - no_main_dependency, - origCommand.GetCommandLines(), - comment.c_str(), - origCommand.GetWorkingDirectory()); + if(cmSourceFile* outsf = + this->Makefile->AddCustomCommandToOutput( + output, depends, no_main_dependency, + origCommand.GetCommandLines(), comment.c_str(), + origCommand.GetWorkingDirectory())) + { + target.AddSourceFile(outsf); + } // Replace the dependencies with the output of this rule so that the // next rule added will run after this one. depends.clear(); depends.push_back(output); - // Add a source file representing this output to the project. - cmSourceFile* outsf = this->Makefile->GetSourceFileWithOutput(output); - target.AddSourceFile(outsf); - // Free the fake output name. delete [] output; } diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index 672edf475..2bb5ad008 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -146,11 +146,10 @@ void cmLocalVisualStudio7Generator::FixGlobalTargets() force += "/"; force += tgt.GetName(); force += "_force"; - this->Makefile->AddCustomCommandToOutput(force.c_str(), no_depends, - no_main_dependency, - force_commands, " ", 0, true); if(cmSourceFile* file = - this->Makefile->GetSourceFileWithOutput(force.c_str())) + this->Makefile->AddCustomCommandToOutput( + force.c_str(), no_depends, no_main_dependency, + force_commands, " ", 0, true)) { tgt.AddSourceFile(file); }