AutoGen: Fix moc and uic dependencies when building Qt itself

When building Qt itself, the moc and uic executables are spcecified
via a generator expression of the form $<TARGET_FILE:Qt6::moc>,
which ends populating Moc's and Uic's 'Executable' field but not the
ExecutableTarget and ExecutableTargetName fields.

In such a scenario, the code in
cmQtAutoGenInitializer::InitAutogenTarget fails to add a dependency
on moc (or uic), because ExecutableTarget is null. First try to add
a dependency on the ExecutableTarget if it's not empty, otherwise try
to add a dependency on the path specified in the 'Executable' field.

Issue: #21118
This commit is contained in:
Alexandru Croitor 2020-08-21 17:55:16 +02:00 committed by Brad King
parent aaa5eab410
commit a48bb185c3

View File

@ -1224,9 +1224,13 @@ bool cmQtAutoGenInitializer::InitAutogenTarget()
if (this->Moc.ExecutableTarget != nullptr) {
dependencies.push_back(this->Moc.ExecutableTarget->Target->GetName());
} else if (!this->Moc.Executable.empty()) {
dependencies.push_back(this->Moc.Executable);
}
if (this->Uic.ExecutableTarget != nullptr) {
dependencies.push_back(this->Uic.ExecutableTarget->Target->GetName());
} else if (!this->Uic.Executable.empty()) {
dependencies.push_back(this->Uic.Executable);
}
// Create the custom command that outputs the timestamp file.