summaryrefslogtreecommitdiffstats
path: root/Source/cmCustomCommand.cxx
diff options
context:
space:
mode:
authorNAKAMURA Takumi <geek4civic@gmail.com>2021-12-12 06:01:20 (GMT)
committerBrad King <brad.king@kitware.com>2021-12-14 15:48:43 (GMT)
commit780341f360773d7b3b766b835bd539f46397e0a6 (patch)
tree767cdbaa73a9b9c7c38a31ab962034f1386d918f /Source/cmCustomCommand.cxx
parenta6fa3fa136c291c36aefbc79b62995a63bf9107b (diff)
downloadCMake-780341f360773d7b3b766b835bd539f46397e0a6.zip
CMake-780341f360773d7b3b766b835bd539f46397e0a6.tar.gz
CMake-780341f360773d7b3b766b835bd539f46397e0a6.tar.bz2
cmCustomCommand: Track main dependency explicitly
Store the main dependency as the first entry in the dependency list plus a boolean member indicating its existence. Note that this slightly changes existing behavior: the main dependency was previously the last entry of the dependency list.
Diffstat (limited to 'Source/cmCustomCommand.cxx')
-rw-r--r--Source/cmCustomCommand.cxx24
1 files changed, 24 insertions, 0 deletions
diff --git a/Source/cmCustomCommand.cxx b/Source/cmCustomCommand.cxx
index f009632..68c65bb 100644
--- a/Source/cmCustomCommand.cxx
+++ b/Source/cmCustomCommand.cxx
@@ -2,6 +2,7 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmCustomCommand.h"
+#include <cassert>
#include <utility>
#include <cmext/algorithm>
@@ -38,9 +39,32 @@ const std::vector<std::string>& cmCustomCommand::GetDepends() const
void cmCustomCommand::SetDepends(std::vector<std::string> depends)
{
+ if (this->HasMainDependency_) {
+ depends.insert(depends.begin(), std::move(this->Depends[0]));
+ }
+
Depends = std::move(depends);
}
+const std::string& cmCustomCommand::GetMainDependency() const
+{
+ assert(this->HasMainDependency_);
+ return this->Depends[0];
+}
+
+void cmCustomCommand::SetMainDependency(std::string main_dependency)
+{
+ if (this->HasMainDependency_) {
+ assert(!main_dependency.empty());
+ this->Depends[0] = std::move(main_dependency);
+ } else if (main_dependency.empty()) {
+ // Do nothing.
+ } else {
+ this->Depends.insert(this->Depends.begin(), std::move(main_dependency));
+ this->HasMainDependency_ = true;
+ }
+}
+
const cmCustomCommandLines& cmCustomCommand::GetCommandLines() const
{
return this->CommandLines;