diff options
author | Joerg Bornemann <joerg.bornemann@qt.io> | 2020-09-01 13:10:41 (GMT) |
---|---|---|
committer | Joerg Bornemann <joerg.bornemann@qt.io> | 2020-09-09 10:51:28 (GMT) |
commit | 9ac3503d30ed46c63c6a733304072d316f0042cf (patch) | |
tree | 675cb23c9b4085509019569a39e7e57b15972021 /Source | |
parent | fff360c60c7e428054306fc0f02126ac7fd34410 (diff) | |
download | CMake-9ac3503d30ed46c63c6a733304072d316f0042cf.zip CMake-9ac3503d30ed46c63c6a733304072d316f0042cf.tar.gz CMake-9ac3503d30ed46c63c6a733304072d316f0042cf.tar.bz2 |
AutoMoc: Re-run moc if a dependency is missing
AutoMoc uses the moc-emitted dependency file of Qt 5.15 to track
dependencies. Such a dependency may well live outside the project and
can vanish, for example when installing a new compiler version.
This situation was detected before, but merely a warning was issued.
Now, we're considering a generated file as out of date if a dependency
is missing and re-generate it.
We also have to remove the missing dependency from the ParseCache.
Otherwise the AUTOMOC target for all generators other than Ninja will
always be out of date.
The ParseCacheChanged flag had to be made atomic, because we're
potentially accessing it from multiple threads. The dependencies vector
itself is not vulnerable in this regard, because there's one vector per
file, and we're accessing exactly one ParseCacheT::FileHandleT per thread.
Fixes: #21136
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmQtAutoMocUic.cxx | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/Source/cmQtAutoMocUic.cxx b/Source/cmQtAutoMocUic.cxx index 71c288c..9cb172b 100644 --- a/Source/cmQtAutoMocUic.cxx +++ b/Source/cmQtAutoMocUic.cxx @@ -192,7 +192,7 @@ public: { public: // -- Parse Cache - bool ParseCacheChanged = false; + std::atomic<bool> ParseCacheChanged = ATOMIC_VAR_INIT(false); cmFileTime ParseCacheTime; ParseCacheT ParseCache; @@ -1777,16 +1777,24 @@ bool cmQtAutoMocUicT::JobProbeDepsMocT::Probe(MappingT const& mapping, { // Check dependency timestamps std::string const sourceDir = SubDirPrefix(sourceFile); - for (std::string const& dep : mapping.SourceFile->ParseData->Moc.Depends) { + auto& dependencies = mapping.SourceFile->ParseData->Moc.Depends; + for (auto it = dependencies.begin(); it != dependencies.end(); ++it) { + auto& dep = *it; + // Find dependency file auto const depMatch = FindDependency(sourceDir, dep); if (depMatch.first.empty()) { - Log().Warning(GenT::MOC, - cmStrCat(MessagePath(sourceFile), " depends on ", - MessagePath(dep), - " but the file does not exist.")); - continue; + if (reason != nullptr) { + *reason = + cmStrCat("Generating ", MessagePath(outputFile), " from ", + MessagePath(sourceFile), ", because its dependency ", + MessagePath(dep), " vanished."); + } + dependencies.erase(it); + BaseEval().ParseCacheChanged = true; + return true; } + // Test if dependency file is older if (outputFileTime.Older(depMatch.second)) { if (reason != nullptr) { |