Merge branch 'fix-target-alias-in-subdir' into release
This commit is contained in:
commit
58a57105d0
|
@ -117,7 +117,7 @@ void cmFLTKWrapUICommand::FinalPass()
|
||||||
// people should add the srcs to the target themselves, but the old command
|
// people should add the srcs to the target themselves, but the old command
|
||||||
// didn't support that, so check and see if they added the files in and if
|
// didn't support that, so check and see if they added the files in and if
|
||||||
// they didn;t then print a warning and add then anyhow
|
// they didn;t then print a warning and add then anyhow
|
||||||
cmTarget* target = this->Makefile->FindTarget(this->Target);
|
cmTarget* target = this->Makefile->FindLocalNonAliasTarget(this->Target);
|
||||||
if(!target)
|
if(!target)
|
||||||
{
|
{
|
||||||
std::string msg =
|
std::string msg =
|
||||||
|
|
|
@ -381,7 +381,7 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// Lookup this target in the current directory.
|
// Lookup this target in the current directory.
|
||||||
if(cmTarget* target=this->Makefile->FindTarget(*targetIt))
|
if(cmTarget* target=this->Makefile->FindLocalNonAliasTarget(*targetIt))
|
||||||
{
|
{
|
||||||
// Found the target. Check its type.
|
// Found the target. Check its type.
|
||||||
if(target->GetType() != cmState::EXECUTABLE &&
|
if(target->GetType() != cmState::EXECUTABLE &&
|
||||||
|
|
|
@ -446,7 +446,7 @@ cmInstallTargetGenerator::GetInstallFilename(cmGeneratorTarget const* target,
|
||||||
|
|
||||||
void cmInstallTargetGenerator::Compute(cmLocalGenerator* lg)
|
void cmInstallTargetGenerator::Compute(cmLocalGenerator* lg)
|
||||||
{
|
{
|
||||||
this->Target = lg->FindGeneratorTarget(this->TargetName);
|
this->Target = lg->FindLocalNonAliasGeneratorTarget(this->TargetName);
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
|
|
|
@ -485,19 +485,9 @@ private:
|
||||||
std::string Name;
|
std::string Name;
|
||||||
};
|
};
|
||||||
|
|
||||||
cmGeneratorTarget* cmLocalGenerator::FindGeneratorTarget(
|
cmGeneratorTarget* cmLocalGenerator::FindLocalNonAliasGeneratorTarget(
|
||||||
const std::string& name) const
|
const std::string& name) const
|
||||||
{
|
{
|
||||||
std::map<std::string, std::string>::const_iterator i =
|
|
||||||
this->AliasTargets.find(name);
|
|
||||||
if (i != this->AliasTargets.end())
|
|
||||||
{
|
|
||||||
std::vector<cmGeneratorTarget*>::const_iterator ai =
|
|
||||||
std::find_if(this->GeneratorTargets.begin(),
|
|
||||||
this->GeneratorTargets.end(),
|
|
||||||
NamedGeneratorTargetFinder(i->second));
|
|
||||||
return *ai;
|
|
||||||
}
|
|
||||||
std::vector<cmGeneratorTarget*>::const_iterator ti =
|
std::vector<cmGeneratorTarget*>::const_iterator ti =
|
||||||
std::find_if(this->GeneratorTargets.begin(),
|
std::find_if(this->GeneratorTargets.begin(),
|
||||||
this->GeneratorTargets.end(),
|
this->GeneratorTargets.end(),
|
||||||
|
@ -506,7 +496,6 @@ cmGeneratorTarget* cmLocalGenerator::FindGeneratorTarget(
|
||||||
{
|
{
|
||||||
return *ti;
|
return *ti;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1839,7 +1828,7 @@ cmLocalGenerator::FindGeneratorTargetToUse(const std::string& name) const
|
||||||
return *imported;
|
return *imported;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(cmGeneratorTarget* t = this->FindGeneratorTarget(name))
|
if(cmGeneratorTarget* t = this->FindLocalNonAliasGeneratorTarget(name))
|
||||||
{
|
{
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
|
@ -129,7 +129,8 @@ public:
|
||||||
void AddImportedGeneratorTarget(cmGeneratorTarget* gt);
|
void AddImportedGeneratorTarget(cmGeneratorTarget* gt);
|
||||||
void AddOwnedImportedGeneratorTarget(cmGeneratorTarget* gt);
|
void AddOwnedImportedGeneratorTarget(cmGeneratorTarget* gt);
|
||||||
|
|
||||||
cmGeneratorTarget* FindGeneratorTarget(const std::string& name) const;
|
cmGeneratorTarget*
|
||||||
|
FindLocalNonAliasGeneratorTarget(const std::string& name) const;
|
||||||
cmGeneratorTarget* FindGeneratorTargetToUse(const std::string& name) const;
|
cmGeneratorTarget* FindGeneratorTargetToUse(const std::string& name) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -4058,25 +4058,13 @@ std::vector<std::string> cmMakefile::GetPropertyKeys() const
|
||||||
return this->StateSnapshot.GetDirectory().GetPropertyKeys();
|
return this->StateSnapshot.GetDirectory().GetPropertyKeys();
|
||||||
}
|
}
|
||||||
|
|
||||||
cmTarget* cmMakefile::FindTarget(const std::string& name,
|
cmTarget* cmMakefile::FindLocalNonAliasTarget(const std::string& name) const
|
||||||
bool excludeAliases) const
|
|
||||||
{
|
{
|
||||||
if (!excludeAliases)
|
|
||||||
{
|
|
||||||
std::map<std::string, std::string>::const_iterator i =
|
|
||||||
this->AliasTargets.find(name);
|
|
||||||
if (i != this->AliasTargets.end())
|
|
||||||
{
|
|
||||||
cmTargets::iterator ai = this->Targets.find(i->second);
|
|
||||||
return &ai->second;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
cmTargets::iterator i = this->Targets.find( name );
|
cmTargets::iterator i = this->Targets.find( name );
|
||||||
if ( i != this->Targets.end() )
|
if ( i != this->Targets.end() )
|
||||||
{
|
{
|
||||||
return &i->second;
|
return &i->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4247,7 +4235,7 @@ cmTarget* cmMakefile::FindTargetToUse(const std::string& name,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Look for a target built in this directory.
|
// Look for a target built in this directory.
|
||||||
if(cmTarget* t = this->FindTarget(name, excludeAliases))
|
if(cmTarget* t = this->FindLocalNonAliasTarget(name))
|
||||||
{
|
{
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
|
@ -388,8 +388,7 @@ public:
|
||||||
}
|
}
|
||||||
std::vector<cmTarget*> GetImportedTargets() const;
|
std::vector<cmTarget*> GetImportedTargets() const;
|
||||||
|
|
||||||
cmTarget* FindTarget(const std::string& name,
|
cmTarget* FindLocalNonAliasTarget(const std::string& name) const;
|
||||||
bool excludeAliases = false) const;
|
|
||||||
|
|
||||||
/** Find a target to use in place of the given name. The target
|
/** Find a target to use in place of the given name. The target
|
||||||
returned may be imported or built within the project. */
|
returned may be imported or built within the project. */
|
||||||
|
|
|
@ -1,3 +1,8 @@
|
||||||
|
|
||||||
add_library(tgt STATIC empty.cpp)
|
add_library(tgt STATIC empty.cpp)
|
||||||
add_library(Sub::tgt ALIAS tgt)
|
add_library(Sub::tgt ALIAS tgt)
|
||||||
|
|
||||||
|
# foo comes from the top-level CMakeLists.txt
|
||||||
|
add_library(Top::foo ALIAS foo)
|
||||||
|
get_target_property(some_prop Top::foo SOME_PROP)
|
||||||
|
target_link_libraries(tgt Top::foo)
|
||||||
|
|
Loading…
Reference in New Issue