cmState: Record imported target names in each directory

Model the change after commit 089868a244 (cmState: Record buildsystem
target names in each directory, 2016-09-16, v3.7.0-rc1~79^2~3).
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index 908b3f0..d2d34f9 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -4134,6 +4134,7 @@
   // 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 d97762b..0b8a64b 100644
--- a/Source/cmState.cxx
+++ b/Source/cmState.cxx
@@ -286,6 +286,7 @@
     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 9ae2861..76201cd 100644
--- a/Source/cmStateDirectory.cxx
+++ b/Source/cmStateDirectory.cxx
@@ -546,3 +546,8 @@
 {
   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 ce00dbb..b8abccb 100644
--- a/Source/cmStateDirectory.h
+++ b/Source/cmStateDirectory.h
@@ -81,6 +81,7 @@
   std::vector<std::string> GetPropertyKeys() const;
 
   void AddNormalTargetName(std::string const& name);
+  void AddImportedTargetName(std::string const& name);
 
 private:
   cmLinkedTree<cmStateDetail::BuildsystemDirectoryStateType>::iterator
diff --git a/Source/cmStatePrivate.h b/Source/cmStatePrivate.h
index a437ce2..6f475f2 100644
--- a/Source/cmStatePrivate.h
+++ b/Source/cmStatePrivate.h
@@ -83,6 +83,7 @@
   std::vector<cmListFileBacktrace> LinkDirectoriesBacktraces;
 
   std::vector<std::string> NormalTargetNames;
+  std::vector<std::string> ImportedTargetNames;
 
   std::string ProjectName;