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