cmMakefile: Add a CreateSource method
The GetOrCreateSource searches the source file listing again, but some callers know that it already didn't exist.
This commit is contained in:
parent
49c830d597
commit
d2803fbac6
|
@ -29,7 +29,7 @@ bool cmGetSourceFilePropertyCommand
|
|||
// for the location we must create a source file first
|
||||
if (!sf && args[2] == "LOCATION")
|
||||
{
|
||||
sf = this->Makefile->GetOrCreateSource(file);
|
||||
sf = this->Makefile->CreateSource(file);
|
||||
}
|
||||
if(sf)
|
||||
{
|
||||
|
|
|
@ -1010,11 +1010,9 @@ cmMakefile::AddCustomCommandToOutput(const std::vector<std::string>& outputs,
|
|||
file = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
else if (!file)
|
||||
{
|
||||
// The main dependency does not have a custom command or we are
|
||||
// allowed to replace it. Use it to store the command.
|
||||
file = this->GetOrCreateSource(main_dependency);
|
||||
file = this->CreateSource(main_dependency);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1041,9 +1039,12 @@ cmMakefile::AddCustomCommandToOutput(const std::vector<std::string>& outputs,
|
|||
}
|
||||
|
||||
// Create a cmSourceFile for the rule file.
|
||||
file = this->GetOrCreateSource(outName, true);
|
||||
if (!file)
|
||||
{
|
||||
file = this->CreateSource(outName, true);
|
||||
file->SetProperty("__CMAKE_RULE", "1");
|
||||
}
|
||||
}
|
||||
|
||||
// Always create the output sources and mark them generated.
|
||||
for(std::vector<std::string>::const_iterator o = outputs.begin();
|
||||
|
@ -3450,6 +3451,19 @@ cmSourceFile* cmMakefile::GetSource(const std::string& sourceName) const
|
|||
return 0;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
cmSourceFile* cmMakefile::CreateSource(const std::string& sourceName,
|
||||
bool generated)
|
||||
{
|
||||
cmSourceFile* sf = new cmSourceFile(this, sourceName);
|
||||
if(generated)
|
||||
{
|
||||
sf->SetProperty("GENERATED", "1");
|
||||
}
|
||||
this->SourceFiles.push_back(sf);
|
||||
return sf;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
cmSourceFile* cmMakefile::GetOrCreateSource(const std::string& sourceName,
|
||||
bool generated)
|
||||
|
@ -3460,13 +3474,7 @@ cmSourceFile* cmMakefile::GetOrCreateSource(const std::string& sourceName,
|
|||
}
|
||||
else
|
||||
{
|
||||
cmSourceFile* sf = new cmSourceFile(this, sourceName);
|
||||
if(generated)
|
||||
{
|
||||
sf->SetProperty("GENERATED", "1");
|
||||
}
|
||||
this->SourceFiles.push_back(sf);
|
||||
return sf;
|
||||
return this->CreateSource(sourceName, generated);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -560,6 +560,13 @@ public:
|
|||
*/
|
||||
cmSourceFile* GetSource(const std::string& sourceName) const;
|
||||
|
||||
/** Create the source file and return it. generated
|
||||
* indicates if it is a generated file, this is used in determining
|
||||
* how to create the source file instance e.g. name
|
||||
*/
|
||||
cmSourceFile* CreateSource(const std::string& sourceName,
|
||||
bool generated = false);
|
||||
|
||||
/** Get a cmSourceFile pointer for a given source name, if the name is
|
||||
* not found, then create the source file and return it. generated
|
||||
* indicates if it is a generated file, this is used in determining
|
||||
|
|
Loading…
Reference in New Issue