cmMakefile: Avoid excess source files

When there are no commands, a main_dependency is not required and when
there are also no dependencies, nothing is required.
This commit is contained in:
Ben Boeckel 2014-03-12 17:29:04 -04:00
parent d2803fbac6
commit dc2e26df01
1 changed files with 25 additions and 22 deletions

View File

@ -989,7 +989,7 @@ cmMakefile::AddCustomCommandToOutput(const std::vector<std::string>& outputs,
// Choose a source file on which to store the custom command. // Choose a source file on which to store the custom command.
cmSourceFile* file = 0; cmSourceFile* file = 0;
if(!main_dependency.empty()) if(!commandLines.empty() && !main_dependency.empty())
{ {
// The main dependency was specified. Use it unless a different // The main dependency was specified. Use it unless a different
// custom command already used it. // custom command already used it.
@ -1257,28 +1257,31 @@ cmMakefile::AddUtilityCommand(const std::string& utilityName,
} }
// Store the custom command in the target. // Store the custom command in the target.
std::string force = this->GetStartOutputDirectory(); if (!commandLines.empty() || !depends.empty())
force += cmake::GetCMakeFilesDirectory(); {
force += "/"; std::string force = this->GetStartOutputDirectory();
force += utilityName; force += cmake::GetCMakeFilesDirectory();
std::string no_main_dependency = ""; force += "/";
bool no_replace = false; force += utilityName;
this->AddCustomCommandToOutput(force, depends, std::string no_main_dependency = "";
no_main_dependency, bool no_replace = false;
commandLines, comment, this->AddCustomCommandToOutput(force, depends,
workingDirectory, no_replace, no_main_dependency,
escapeOldStyle); commandLines, comment,
cmSourceFile* sf = target->AddSourceCMP0049(force); workingDirectory, no_replace,
escapeOldStyle);
cmSourceFile* sf = target->AddSourceCMP0049(force);
// The output is not actually created so mark it symbolic. // The output is not actually created so mark it symbolic.
if(sf) if(sf)
{ {
sf->SetProperty("SYMBOLIC", "1"); sf->SetProperty("SYMBOLIC", "1");
} }
else else
{ {
cmSystemTools::Error("Could not get source file entry for ", cmSystemTools::Error("Could not get source file entry for ",
force.c_str()); force.c_str());
}
} }
return target; return target;
} }