Merge topic 'dir-IMPORTED_TARGETS'

e13704ce72 Add directory property to list imported targets
ea6d338ea1 cmState: Record imported target names in each directory

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !6215
This commit is contained in:
Brad King
2021-06-11 10:11:37 +00:00
committed by Kitware Robot
12 changed files with 50 additions and 0 deletions

View File

@@ -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));

View File

@@ -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();
}

View File

@@ -8,7 +8,9 @@
#include <vector>
#include <cm/iterator>
#include <cm/string_view>
#include <cmext/algorithm>
#include <cmext/string_view>
#include "cmAlgorithms.h"
#include "cmProperty.h"
@@ -475,6 +477,10 @@ cmProp cmStateDirectory::GetProperty(const std::string& prop, bool chain) const
output = cmJoin(this->DirectoryState->NormalTargetNames, ";");
return &output;
}
if (prop == "IMPORTED_TARGETS"_s) {
output = cmJoin(this->DirectoryState->ImportedTargetNames, ";");
return &output;
}
if (prop == "LISTFILE_STACK") {
std::vector<std::string> listFiles;
@@ -546,3 +552,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);
}

View File

@@ -81,6 +81,7 @@ public:
std::vector<std::string> GetPropertyKeys() const;
void AddNormalTargetName(std::string const& name);
void AddImportedTargetName(std::string const& name);
private:
cmLinkedTree<cmStateDetail::BuildsystemDirectoryStateType>::iterator

View File

@@ -83,6 +83,7 @@ struct cmStateDetail::BuildsystemDirectoryStateType
std::vector<cmListFileBacktrace> LinkDirectoriesBacktraces;
std::vector<std::string> NormalTargetNames;
std::vector<std::string> ImportedTargetNames;
std::string ProjectName;