|
@@ -41,6 +41,7 @@
|
|
|
|
|
|
#include <stack>
|
|
|
#include <ctype.h> // for isspace
|
|
|
+#include <assert.h>
|
|
|
|
|
|
class cmMakefile::Internals
|
|
|
{
|
|
@@ -1437,6 +1438,14 @@ void cmMakefile::AddLinkDirectoryForTarget(const char *target,
|
|
|
cmTargets::iterator i = this->Targets.find(target);
|
|
|
if ( i != this->Targets.end())
|
|
|
{
|
|
|
+ if(this->IsAlias(target))
|
|
|
+ {
|
|
|
+ cmOStringStream e;
|
|
|
+ e << "ALIAS target \"" << target << "\" "
|
|
|
+ << "may not be linked into another target.";
|
|
|
+ this->IssueMessage(cmake::FATAL_ERROR, e.str().c_str());
|
|
|
+ return;
|
|
|
+ }
|
|
|
i->second.AddLinkDirectory( d );
|
|
|
}
|
|
|
else
|
|
@@ -1923,6 +1932,12 @@ void cmMakefile::AddGlobalLinkInformation(const char* name, cmTarget& target)
|
|
|
}
|
|
|
|
|
|
|
|
|
+void cmMakefile::AddAlias(const char* lname, cmTarget *tgt)
|
|
|
+{
|
|
|
+ this->AliasTargets[lname] = tgt;
|
|
|
+ this->LocalGenerator->GetGlobalGenerator()->AddAlias(lname, tgt);
|
|
|
+}
|
|
|
+
|
|
|
cmTarget* cmMakefile::AddLibrary(const char* lname, cmTarget::TargetType type,
|
|
|
const std::vector<std::string> &srcs,
|
|
|
bool excludeFromAll)
|
|
@@ -3758,8 +3773,17 @@ const char* cmMakefile::GetFeature(const char* feature, const char* config)
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
-cmTarget* cmMakefile::FindTarget(const char* name)
|
|
|
+cmTarget* cmMakefile::FindTarget(const char* name, bool excludeAliases)
|
|
|
{
|
|
|
+ if (!excludeAliases)
|
|
|
+ {
|
|
|
+ std::map<std::string, cmTarget*>::iterator i
|
|
|
+ = this->AliasTargets.find(name);
|
|
|
+ if (i != this->AliasTargets.end())
|
|
|
+ {
|
|
|
+ return i->second;
|
|
|
+ }
|
|
|
+ }
|
|
|
cmTargets& tgts = this->GetTargets();
|
|
|
|
|
|
cmTargets::iterator i = tgts.find ( name );
|
|
@@ -4184,7 +4208,7 @@ cmMakefile::AddImportedTarget(const char* name, cmTarget::TargetType type,
|
|
|
}
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
-cmTarget* cmMakefile::FindTargetToUse(const char* name)
|
|
|
+cmTarget* cmMakefile::FindTargetToUse(const char* name, bool excludeAliases)
|
|
|
{
|
|
|
// Look for an imported target. These take priority because they
|
|
|
// are more local in scope and do not have to be globally unique.
|
|
@@ -4196,15 +4220,25 @@ cmTarget* cmMakefile::FindTargetToUse(const char* name)
|
|
|
}
|
|
|
|
|
|
// Look for a target built in this directory.
|
|
|
- if(cmTarget* t = this->FindTarget(name))
|
|
|
+ if(cmTarget* t = this->FindTarget(name, excludeAliases))
|
|
|
{
|
|
|
return t;
|
|
|
}
|
|
|
|
|
|
// Look for a target built in this project.
|
|
|
- return this->LocalGenerator->GetGlobalGenerator()->FindTarget(0, name);
|
|
|
+ return this->LocalGenerator->GetGlobalGenerator()->FindTarget(0, name,
|
|
|
+ excludeAliases);
|
|
|
}
|
|
|
|
|
|
+//----------------------------------------------------------------------------
|
|
|
+bool cmMakefile::IsAlias(const char *name)
|
|
|
+{
|
|
|
+ if (this->AliasTargets.find(name) != this->AliasTargets.end())
|
|
|
+ return true;
|
|
|
+ return this->GetLocalGenerator()->GetGlobalGenerator()->IsAlias(name);
|
|
|
+}
|
|
|
+
|
|
|
+//----------------------------------------------------------------------------
|
|
|
cmGeneratorTarget* cmMakefile::FindGeneratorTargetToUse(const char* name)
|
|
|
{
|
|
|
cmTarget *t = this->FindTargetToUse(name);
|
|
@@ -4215,6 +4249,14 @@ cmGeneratorTarget* cmMakefile::FindGeneratorTargetToUse(const char* name)
|
|
|
bool cmMakefile::EnforceUniqueName(std::string const& name, std::string& msg,
|
|
|
bool isCustom)
|
|
|
{
|
|
|
+ if(this->IsAlias(name.c_str()))
|
|
|
+ {
|
|
|
+ cmOStringStream e;
|
|
|
+ e << "cannot create target \"" << name
|
|
|
+ << "\" because an alias with the same name already exists.";
|
|
|
+ msg = e.str();
|
|
|
+ return false;
|
|
|
+ }
|
|
|
if(cmTarget* existing = this->FindTargetToUse(name.c_str()))
|
|
|
{
|
|
|
// The name given conflicts with an existing target. Produce an
|