mirror of
https://github.com/Kitware/CMake.git
synced 2026-02-18 13:10:17 -06:00
cmQtAutoGenInitializer: De-duplicate autogen/timestamp target depend logic
We place the same target ordering dependencies on either the `_autogen_timestamp_deps` target or the `_autogen` target. Refactor the logic to avoid duplicating that code.
This commit is contained in:
@@ -1366,6 +1366,7 @@ bool cmQtAutoGenInitializer::InitAutogenTarget()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cmTarget* timestampTarget = nullptr;
|
||||||
std::vector<std::string> dependencies(
|
std::vector<std::string> dependencies(
|
||||||
this->AutogenTarget.DependFiles.begin(),
|
this->AutogenTarget.DependFiles.begin(),
|
||||||
this->AutogenTarget.DependFiles.end());
|
this->AutogenTarget.DependFiles.end());
|
||||||
@@ -1390,24 +1391,8 @@ bool cmQtAutoGenInitializer::InitAutogenTarget()
|
|||||||
cc->SetWorkingDirectory(this->Dir.Work.c_str());
|
cc->SetWorkingDirectory(this->Dir.Work.c_str());
|
||||||
cc->SetDepends(dependencies);
|
cc->SetDepends(dependencies);
|
||||||
cc->SetEscapeOldStyle(false);
|
cc->SetEscapeOldStyle(false);
|
||||||
cmTarget* timestampTarget = this->LocalGen->AddUtilityCommand(
|
timestampTarget = this->LocalGen->AddUtilityCommand(timestampTargetName,
|
||||||
timestampTargetName, true, std::move(cc));
|
true, std::move(cc));
|
||||||
|
|
||||||
// Add additional autogen target dependencies to
|
|
||||||
// '_autogen_timestamp_deps'.
|
|
||||||
for (const cmTarget* t : this->AutogenTarget.DependTargets) {
|
|
||||||
timestampTarget->AddUtility(t->GetName(), false, this->Makefile);
|
|
||||||
}
|
|
||||||
|
|
||||||
auto const isMake =
|
|
||||||
this->GlobalGen->GetName().find("Make") != std::string::npos;
|
|
||||||
if (this->AutogenTarget.DependOrigin && isMake) {
|
|
||||||
for (BT<std::pair<std::string, bool>> const& depName :
|
|
||||||
this->GenTarget->GetUtilities()) {
|
|
||||||
timestampTarget->AddUtility(depName.Value.first, false,
|
|
||||||
this->Makefile);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
this->LocalGen->AddGeneratorTarget(
|
this->LocalGen->AddGeneratorTarget(
|
||||||
cm::make_unique<cmGeneratorTarget>(timestampTarget, this->LocalGen));
|
cm::make_unique<cmGeneratorTarget>(timestampTarget, this->LocalGen));
|
||||||
@@ -1471,18 +1456,19 @@ bool cmQtAutoGenInitializer::InitAutogenTarget()
|
|||||||
this->LocalGen->AddGeneratorTarget(
|
this->LocalGen->AddGeneratorTarget(
|
||||||
cm::make_unique<cmGeneratorTarget>(autogenTarget, this->LocalGen));
|
cm::make_unique<cmGeneratorTarget>(autogenTarget, this->LocalGen));
|
||||||
|
|
||||||
|
// Order the autogen target(s) just before the original target.
|
||||||
|
cmTarget* orderTarget = timestampTarget ? timestampTarget : autogenTarget;
|
||||||
// Forward origin utilities to autogen target
|
// Forward origin utilities to autogen target
|
||||||
if (this->AutogenTarget.DependOrigin) {
|
if (this->AutogenTarget.DependOrigin) {
|
||||||
for (BT<std::pair<std::string, bool>> const& depName :
|
for (BT<std::pair<std::string, bool>> const& depName :
|
||||||
this->GenTarget->GetUtilities()) {
|
this->GenTarget->GetUtilities()) {
|
||||||
autogenTarget->AddUtility(depName.Value.first, false, this->Makefile);
|
orderTarget->AddUtility(depName.Value.first, false, this->Makefile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!useDepfile) {
|
|
||||||
// Add additional autogen target dependencies to autogen target
|
// Add additional autogen target dependencies to autogen target
|
||||||
for (cmTarget const* depTarget : this->AutogenTarget.DependTargets) {
|
for (cmTarget const* depTarget : this->AutogenTarget.DependTargets) {
|
||||||
autogenTarget->AddUtility(depTarget->GetName(), false, this->Makefile);
|
orderTarget->AddUtility(depTarget->GetName(), false, this->Makefile);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set FOLDER property in autogen target
|
// Set FOLDER property in autogen target
|
||||||
|
|||||||
Reference in New Issue
Block a user