diff options
Diffstat (limited to 'Source/cmAddExecutableCommand.cxx')
-rw-r--r-- | Source/cmAddExecutableCommand.cxx | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/Source/cmAddExecutableCommand.cxx b/Source/cmAddExecutableCommand.cxx index 6dd8e5c..5785259 100644 --- a/Source/cmAddExecutableCommand.cxx +++ b/Source/cmAddExecutableCommand.cxx @@ -30,6 +30,7 @@ bool cmAddExecutableCommand bool excludeFromAll = false; bool importTarget = false; bool importGlobal = false; + bool isAlias = false; while ( s != args.end() ) { if (*s == "WIN32") @@ -57,6 +58,11 @@ bool cmAddExecutableCommand ++s; importGlobal = true; } + else if(*s == "ALIAS") + { + ++s; + isAlias = true; + } else { break; @@ -83,6 +89,72 @@ bool cmAddExecutableCommand } return false; } + if (isAlias) + { + if(!cmGeneratorExpression::IsValidTargetName(exename.c_str())) + { + this->SetError(("Invalid name for ALIAS: " + exename).c_str()); + return false; + } + if(excludeFromAll) + { + this->SetError("EXCLUDE_FROM_ALL with ALIAS makes no sense."); + return false; + } + if(importTarget || importGlobal) + { + this->SetError("IMPORTED with ALIAS is not allowed."); + return false; + } + if(args.size() != 3) + { + cmOStringStream e; + e << "ALIAS requires exactly one target argument."; + this->SetError(e.str().c_str()); + return false; + } + + const char *aliasedName = s->c_str(); + if(this->Makefile->IsAlias(aliasedName)) + { + cmOStringStream e; + e << "cannot create ALIAS target \"" << exename + << "\" because target \"" << aliasedName << "\" is itself an ALIAS."; + this->SetError(e.str().c_str()); + return false; + } + cmTarget *aliasedTarget = + this->Makefile->FindTargetToUse(aliasedName, true); + if(!aliasedTarget) + { + cmOStringStream e; + e << "cannot create ALIAS target \"" << exename + << "\" because target \"" << aliasedName << "\" does not already " + "exist."; + this->SetError(e.str().c_str()); + return false; + } + cmTarget::TargetType type = aliasedTarget->GetType(); + if(type != cmTarget::EXECUTABLE) + { + cmOStringStream e; + e << "cannot create ALIAS target \"" << exename + << "\" because target \"" << aliasedName << "\" is not an " + "executable."; + this->SetError(e.str().c_str()); + return false; + } + if(aliasedTarget->IsImported()) + { + cmOStringStream e; + e << "cannot create ALIAS target \"" << exename + << "\" because target \"" << aliasedName << "\" is IMPORTED."; + this->SetError(e.str().c_str()); + return false; + } + this->Makefile->AddAlias(exename.c_str(), aliasedTarget); + return true; + } // Handle imported target creation. if(importTarget) |