mirror of
https://github.com/Kitware/CMake.git
synced 2025-10-14 19:08:07 +08:00
cmGlobalGenerator: Simplify collection of targets under a project()
This commit is contained in:
@@ -3497,10 +3497,11 @@ void cmGlobalGenerator::GetFilesReplacedDuringGenerate(
|
||||
std::back_inserter(filenames));
|
||||
}
|
||||
|
||||
void cmGlobalGenerator::GetTargetSets(
|
||||
TargetDependSet& projectTargets, TargetDependSet& originalTargets,
|
||||
cmLocalGenerator* root, std::vector<cmLocalGenerator*>& generators)
|
||||
cmGlobalGenerator::TargetDependSet cmGlobalGenerator::GetTargetsForProject(
|
||||
cmLocalGenerator const* root,
|
||||
std::vector<cmLocalGenerator*> const& generators) const
|
||||
{
|
||||
TargetDependSet projectTargets;
|
||||
// loop over all local generators
|
||||
for (auto* generator : generators) {
|
||||
// check to make sure generator is not excluded
|
||||
@@ -3513,12 +3514,11 @@ void cmGlobalGenerator::GetTargetSets(
|
||||
target->GetLocalGenerator() != root) {
|
||||
continue;
|
||||
}
|
||||
// put the target in the set of original targets
|
||||
originalTargets.insert(target.get());
|
||||
// Get the set of targets that depend on target
|
||||
this->AddTargetDepends(target.get(), projectTargets);
|
||||
}
|
||||
}
|
||||
return projectTargets;
|
||||
}
|
||||
|
||||
bool cmGlobalGenerator::IsRootOnlyTarget(cmGeneratorTarget* target) const
|
||||
@@ -3528,7 +3528,7 @@ bool cmGlobalGenerator::IsRootOnlyTarget(cmGeneratorTarget* target) const
|
||||
}
|
||||
|
||||
void cmGlobalGenerator::AddTargetDepends(cmGeneratorTarget const* target,
|
||||
TargetDependSet& projectTargets)
|
||||
TargetDependSet& projectTargets) const
|
||||
{
|
||||
// add the target itself
|
||||
if (projectTargets.insert(target).second) {
|
||||
|
@@ -704,14 +704,15 @@ public:
|
||||
cmXcFrameworkPlist const& content);
|
||||
|
||||
protected:
|
||||
// for a project collect all its targets by following depend
|
||||
// information, and also collect all the targets
|
||||
void GetTargetSets(TargetDependSet& projectTargets,
|
||||
TargetDependSet& originalTargets, cmLocalGenerator* root,
|
||||
std::vector<cmLocalGenerator*>& generators);
|
||||
/** Get all targets produced under the given root, plus the transitive
|
||||
closure of targets on which they depend, possibly from other dirs. */
|
||||
TargetDependSet GetTargetsForProject(
|
||||
cmLocalGenerator const* root,
|
||||
std::vector<cmLocalGenerator*> const& generators) const;
|
||||
|
||||
bool IsRootOnlyTarget(cmGeneratorTarget* target) const;
|
||||
void AddTargetDepends(cmGeneratorTarget const* target,
|
||||
TargetDependSet& projectTargets);
|
||||
TargetDependSet& projectTargets) const;
|
||||
void SetLanguageEnabledFlag(std::string const& l, cmMakefile* mf);
|
||||
void SetLanguageEnabledMaps(std::string const& l, cmMakefile* mf);
|
||||
void FillExtensionToLanguageMap(std::string const& l, cmMakefile* mf);
|
||||
|
@@ -439,9 +439,8 @@ void cmGlobalGhsMultiGenerator::OutputTopLevelProject(
|
||||
|
||||
// Collect all targets under this root generator and the transitive
|
||||
// closure of their dependencies.
|
||||
TargetDependSet projectTargets;
|
||||
TargetDependSet originalTargets;
|
||||
this->GetTargetSets(projectTargets, originalTargets, root, generators);
|
||||
TargetDependSet const projectTargets =
|
||||
this->GetTargetsForProject(root, generators);
|
||||
OrderedTargetDependSet sortedProjectTargets(projectTargets, "");
|
||||
this->ProjectTargets.clear();
|
||||
for (cmGeneratorTarget const* t : sortedProjectTargets) {
|
||||
|
@@ -342,9 +342,8 @@ void cmGlobalVisualStudio7Generator::OutputSLNFile(
|
||||
|
||||
// Collect all targets under this root generator and the transitive
|
||||
// closure of their dependencies.
|
||||
TargetDependSet projectTargets;
|
||||
TargetDependSet originalTargets;
|
||||
this->GetTargetSets(projectTargets, originalTargets, root, generators);
|
||||
TargetDependSet const projectTargets =
|
||||
this->GetTargetsForProject(root, generators);
|
||||
OrderedTargetDependSet orderedProjectTargets(
|
||||
projectTargets, this->GetStartupProjectName(root));
|
||||
|
||||
|
Reference in New Issue
Block a user