summaryrefslogtreecommitdiffstats
path: root/Source/cmMakefile.cxx
diff options
context:
space:
mode:
authorBen Boeckel <ben.boeckel@kitware.com>2014-03-11 22:04:11 (GMT)
committerBen Boeckel <ben.boeckel@kitware.com>2014-07-08 14:13:50 (GMT)
commitd2803fbac6ca20c998ff5364e79f0841eba6c579 (patch)
tree3367bc50946dc20bb1ba0dbcd3c3904b82a58833 /Source/cmMakefile.cxx
parent49c830d597bbd8322c7b41847eac3012064b0b7d (diff)
downloadCMake-d2803fbac6ca20c998ff5364e79f0841eba6c579.zip
CMake-d2803fbac6ca20c998ff5364e79f0841eba6c579.tar.gz
CMake-d2803fbac6ca20c998ff5364e79f0841eba6c579.tar.bz2
cmMakefile: Add a CreateSource method
The GetOrCreateSource searches the source file listing again, but some callers know that it already didn't exist.
Diffstat (limited to 'Source/cmMakefile.cxx')
-rw-r--r--Source/cmMakefile.cxx34
1 files changed, 21 insertions, 13 deletions
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index 412c998..c4543d7 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -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,8 +1039,11 @@ cmMakefile::AddCustomCommandToOutput(const std::vector<std::string>& outputs,
}
// Create a cmSourceFile for the rule file.
- file = this->GetOrCreateSource(outName, true);
- file->SetProperty("__CMAKE_RULE", "1");
+ if (!file)
+ {
+ file = this->CreateSource(outName, true);
+ file->SetProperty("__CMAKE_RULE", "1");
+ }
}
// Always create the output sources and mark them generated.
@@ -3451,6 +3452,19 @@ cmSourceFile* cmMakefile::GetSource(const std::string& sourceName) const
}
//----------------------------------------------------------------------------
+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);
}
}