diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 908b3f0d25..d2d34f9fb7 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -4134,6 +4134,7 @@ cmTarget* cmMakefile::AddImportedTarget(const std::string& name, // Add to the set of available imported targets. this->ImportedTargets[name] = target.get(); this->GetGlobalGenerator()->IndexTarget(target.get()); + this->GetStateSnapshot().GetDirectory().AddImportedTargetName(name); // Transfer ownership to this cmMakefile object. this->ImportedTargetsOwned.push_back(std::move(target)); diff --git a/Source/cmState.cxx b/Source/cmState.cxx index d97762bb6c..0b8a64b90e 100644 --- a/Source/cmState.cxx +++ b/Source/cmState.cxx @@ -286,6 +286,7 @@ cmStateSnapshot cmState::Reset() it->LinkDirectoriesBacktraces.clear(); it->DirectoryEnd = pos; it->NormalTargetNames.clear(); + it->ImportedTargetNames.clear(); it->Properties.Clear(); it->Children.clear(); } diff --git a/Source/cmStateDirectory.cxx b/Source/cmStateDirectory.cxx index 9ae2861574..76201cd8f8 100644 --- a/Source/cmStateDirectory.cxx +++ b/Source/cmStateDirectory.cxx @@ -546,3 +546,8 @@ void cmStateDirectory::AddNormalTargetName(std::string const& name) { this->DirectoryState->NormalTargetNames.push_back(name); } + +void cmStateDirectory::AddImportedTargetName(std::string const& name) +{ + this->DirectoryState->ImportedTargetNames.emplace_back(name); +} diff --git a/Source/cmStateDirectory.h b/Source/cmStateDirectory.h index ce00dbb3c3..b8abccb81e 100644 --- a/Source/cmStateDirectory.h +++ b/Source/cmStateDirectory.h @@ -81,6 +81,7 @@ public: std::vector GetPropertyKeys() const; void AddNormalTargetName(std::string const& name); + void AddImportedTargetName(std::string const& name); private: cmLinkedTree::iterator diff --git a/Source/cmStatePrivate.h b/Source/cmStatePrivate.h index a437ce2efc..6f475f2eea 100644 --- a/Source/cmStatePrivate.h +++ b/Source/cmStatePrivate.h @@ -83,6 +83,7 @@ struct cmStateDetail::BuildsystemDirectoryStateType std::vector LinkDirectoriesBacktraces; std::vector NormalTargetNames; + std::vector ImportedTargetNames; std::string ProjectName;