BUG: Fix crash when adding a custom command to a source file that cannot be created.

This commit is contained in:
Brad King 2004-08-04 17:24:21 -04:00
parent 023f5d1f25
commit 3c5bccf8a1
1 changed files with 15 additions and 7 deletions

View File

@ -669,13 +669,18 @@ AddCustomCommandToOutput(const char* outputIn,
} }
// create a cmSourceFile for the output // create a cmSourceFile for the output
file = this->GetOrCreateSource(outName.c_str(), true); file = this->GetOrCreateSource(outName.c_str(), true);
// always mark as generated if(file)
file->SetProperty("GENERATED","1"); {
// always mark as generated
file->SetProperty("GENERATED","1");
}
} }
// always create the output and mark it generated // always create the output and mark it generated
cmSourceFile *out = this->GetOrCreateSource(output.c_str(), true); if(cmSourceFile *out = this->GetOrCreateSource(output.c_str(), true))
out->SetProperty("GENERATED","1"); {
out->SetProperty("GENERATED","1");
}
std::vector<std::string> depends2(depends); std::vector<std::string> depends2(depends);
if (main_dependency && main_dependency[0] != '\0') if (main_dependency && main_dependency[0] != '\0')
@ -689,11 +694,14 @@ AddCustomCommandToOutput(const char* outputIn,
{ {
cc->SetComment(comment); cc->SetComment(comment);
} }
if (file->GetCustomCommand()) if(file)
{ {
delete file->GetCustomCommand(); if (file->GetCustomCommand())
{
delete file->GetCustomCommand();
}
file->SetCustomCommand(cc);
} }
file->SetCustomCommand(cc);
} }
void cmMakefile:: void cmMakefile::