From 952fc65d140a1b36fc2e580d7ca89de231a04412 Mon Sep 17 00:00:00 2001 From: Sebastian Holtermann Date: Thu, 10 Aug 2017 18:27:52 +0200 Subject: Autogen: Clear sources meta data cache Adds cmGeneratorTarget::clearSourcesCache() which clears the cache of precomputed sources lists and object names. The cache gets recomputed on demand. Clearing the cache is necessary in case an OBJECT library gets a source added after a target (ORIGIN) that includes it computed it's external sources cache. This may happen in AUTOMOC when ORIGIN is processed before the OBJECT library which gets a mocs_compilation.cpp file added. Closes #17152 Closes #17139 Closes #17085 Closes #15967 --- Source/cmGeneratorTarget.cxx | 10 ++++++++-- Source/cmGeneratorTarget.h | 5 +++++ Source/cmQtAutoGeneratorInitializer.cxx | 6 ++++++ 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 329c7a9..95f4543 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -326,6 +326,13 @@ std::string cmGeneratorTarget::GetOutputName( return i->second; } +void cmGeneratorTarget::ClearSourcesCache() +{ + this->KindedSourcesMap.clear(); + this->LinkImplementationLanguageIsContextDependent = true; + this->Objects.clear(); +} + void cmGeneratorTarget::AddSourceCommon(const std::string& src) { cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); @@ -333,8 +340,7 @@ void cmGeneratorTarget::AddSourceCommon(const std::string& src) CM_AUTO_PTR cge = ge.Parse(src); cge->SetEvaluateForBuildsystem(true); this->SourceEntries.push_back(new TargetPropertyEntry(cge)); - this->KindedSourcesMap.clear(); - this->LinkImplementationLanguageIsContextDependent = true; + this->ClearSourcesCache(); } void cmGeneratorTarget::AddSource(const std::string& src) diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 52147e3..b5f7f6e 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -491,6 +491,11 @@ public: std::string GetOutputName(const std::string& config, cmStateEnums::ArtifactType artifact) const; + /** Clears cached meta data for local and external source files. + * The meta data will be recomputed on demand. + */ + void ClearSourcesCache(); + void AddSource(const std::string& src); void AddTracedSources(std::vector const& srcs); diff --git a/Source/cmQtAutoGeneratorInitializer.cxx b/Source/cmQtAutoGeneratorInitializer.cxx index 5a06730..2cf2ee9 100644 --- a/Source/cmQtAutoGeneratorInitializer.cxx +++ b/Source/cmQtAutoGeneratorInitializer.cxx @@ -919,6 +919,12 @@ void cmQtAutoGeneratorInitializer::InitializeAutogenTarget( } } + // cmGeneratorTarget::GetConfigCommonSourceFiles computes the target's + // sources meta data cache. Clear it so that OBJECT library targets that + // are AUTOGEN initialized after this target get their added + // mocs_compilation.cpp source acknowledged by this target. + target->ClearSourcesCache(); + // Convert std::set to std::vector const std::vector autogenDepends(autogenDependsSet.begin(), autogenDependsSet.end()); -- cgit v0.12