summaryrefslogtreecommitdiffstats
path: root/Source/cmQtAutoGenInitializer.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2020-08-05 19:42:39 (GMT)
committerBrad King <brad.king@kitware.com>2020-08-05 19:42:39 (GMT)
commit9a9ed4b9d3f9658fa0615bb3cef601c5d396bf3b (patch)
treea250ea9bb63378aa00b46916ecdf04b47dba2e53 /Source/cmQtAutoGenInitializer.cxx
parent63a65baf4c343c73b2142078ef0045d3711dea1d (diff)
parent7445c9a58a2444c8918e81a9264b1584001ca013 (diff)
downloadCMake-9a9ed4b9d3f9658fa0615bb3cef601c5d396bf3b.zip
CMake-9a9ed4b9d3f9658fa0615bb3cef601c5d396bf3b.tar.gz
CMake-9a9ed4b9d3f9658fa0615bb3cef601c5d396bf3b.tar.bz2
Merge branch 'backport-3.17-automoc_timestamp_deps'
Diffstat (limited to 'Source/cmQtAutoGenInitializer.cxx')
-rw-r--r--Source/cmQtAutoGenInitializer.cxx47
1 files changed, 45 insertions, 2 deletions
diff --git a/Source/cmQtAutoGenInitializer.cxx b/Source/cmQtAutoGenInitializer.cxx
index 511a018..1132852 100644
--- a/Source/cmQtAutoGenInitializer.cxx
+++ b/Source/cmQtAutoGenInitializer.cxx
@@ -1182,11 +1182,54 @@ bool cmQtAutoGenInitializer::InitAutogenTarget()
if (useNinjaDepfile) {
// Create a custom command that generates a timestamp file and
// has a depfile assigned. The depfile is created by JobDepFilesMergeT.
-
- // Add additional autogen target dependencies
+ //
+ // Also create an additional '_autogen_timestamp_deps' that the custom
+ // command will depend on. It will have no sources or commands to
+ // execute, but it will have dependencies that would originally be
+ // assigned to the pre-Qt 5.15 'autogen' target. These dependencies will
+ // serve as a list of order-only dependencies for the custom command,
+ // without forcing the custom command to re-execute.
+ //
+ // The dependency tree would then look like
+ // '_autogen_timestamp_deps (order-only)' <- '/timestamp' file <-
+ // '_autogen' target.
+ const auto timestampTargetName =
+ cmStrCat(this->GenTarget->GetName(), "_autogen_timestamp_deps");
+ std::vector<std::string> timestampTargetProvides;
+ cmCustomCommandLines timestampTargetCommandLines;
+
+ // Add additional autogen target dependencies to
+ // '_autogen_timestamp_deps'.
for (const cmTarget* t : this->AutogenTarget.DependTargets) {
dependencies.push_back(t->GetName());
}
+
+ cmTarget* timestampTarget = this->LocalGen->AddUtilityCommand(
+ timestampTargetName, true, this->Dir.Work.c_str(),
+ /*byproducts=*/timestampTargetProvides,
+ /*depends=*/dependencies, timestampTargetCommandLines, false, nullptr);
+ this->LocalGen->AddGeneratorTarget(
+ cm::make_unique<cmGeneratorTarget>(timestampTarget, this->LocalGen));
+
+ // Set FOLDER property on the timestamp target, so it appears in the
+ // appropriate folder in an IDE or in the file api.
+ if (!this->TargetsFolder.empty()) {
+ timestampTarget->SetProperty("FOLDER", this->TargetsFolder);
+ }
+
+ // Make '/timestamp' file depend on '_autogen_timestamp_deps' and on the
+ // moc and uic executables (whichever are enabled).
+ dependencies.clear();
+ dependencies.push_back(timestampTargetName);
+
+ if (this->Moc.ExecutableTarget != nullptr) {
+ dependencies.push_back(this->Moc.ExecutableTarget->Target->GetName());
+ }
+ if (this->Uic.ExecutableTarget != nullptr) {
+ dependencies.push_back(this->Uic.ExecutableTarget->Target->GetName());
+ }
+
+ // Create the custom command that outputs the timestamp file.
const char timestampFileName[] = "timestamp";
const std::string outputFile =
cmStrCat(this->Dir.Build, "/", timestampFileName);