diff options
author | Sebastian Holtermann <sebholt@xwmw.org> | 2019-01-17 10:14:38 (GMT) |
---|---|---|
committer | Sebastian Holtermann <sebholt@xwmw.org> | 2019-01-18 12:47:23 (GMT) |
commit | a42b700cc254e284892821dea06ac265744a0939 (patch) | |
tree | f821db3f66420437cb5f9132bc8dbe60594f6df6 /Source/cmTarget.cxx | |
parent | a61c061b6143cb6d8920b1b5796a867c0f104556 (diff) | |
download | CMake-a42b700cc254e284892821dea06ac265744a0939.zip CMake-a42b700cc254e284892821dea06ac265744a0939.tar.gz CMake-a42b700cc254e284892821dea06ac265744a0939.tar.bz2 |
cmTarget,cmGeneratorTarget: Add optional `before` parameter to AddSource
The new optional `before` parameter in `cmTarget::AddSource` and
`cmGeneratorTarget::AddSource` allows to prepend a source file
to the sources list instead of appending it.
Diffstat (limited to 'Source/cmTarget.cxx')
-rw-r--r-- | Source/cmTarget.cxx | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index a94cf6a..25f021b 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -662,7 +662,7 @@ public: } }; -cmSourceFile* cmTarget::AddSource(const std::string& src) +cmSourceFile* cmTarget::AddSource(const std::string& src, bool before) { cmSourceFileLocation sfl(this->Makefile, src, cmSourceFileLocationKind::Known); @@ -671,8 +671,14 @@ cmSourceFile* cmTarget::AddSource(const std::string& src) TargetPropertyEntryFinder(sfl)) == this->Internal->SourceEntries.end()) { cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); - this->Internal->SourceEntries.push_back(src); - this->Internal->SourceBacktraces.push_back(lfbt); + this->Internal->SourceEntries.insert( + before ? this->Internal->SourceEntries.begin() + : this->Internal->SourceEntries.end(), + src); + this->Internal->SourceBacktraces.insert( + before ? this->Internal->SourceBacktraces.begin() + : this->Internal->SourceBacktraces.end(), + lfbt); } if (cmGeneratorExpression::Find(src) != std::string::npos) { return nullptr; |