diff options
author | Kévin THIERRY <kevin.thierry@open.eurogiciel.org> | 2014-12-23 09:30:24 +0100 |
---|---|---|
committer | Kévin THIERRY <kevin.thierry@open.eurogiciel.org> | 2014-12-23 09:30:24 +0100 |
commit | 317dbdb79761ef65e45c7358cfc7571c6afa54ad (patch) | |
tree | d6e8d59029aea04ca4a0579fb1c19c3e493af78f /Source/cmAddLibraryCommand.cxx | |
parent | 297c63fa65327491a2b50e521b661c5835a19fe4 (diff) | |
download | cmake-317dbdb79761ef65e45c7358cfc7571c6afa54ad.tar.gz cmake-317dbdb79761ef65e45c7358cfc7571c6afa54ad.tar.bz2 cmake-317dbdb79761ef65e45c7358cfc7571c6afa54ad.zip |
Imported Upstream version 2.8.12.2upstream/2.8.12.2sandbox/kevinthierry/upstream
Diffstat (limited to 'Source/cmAddLibraryCommand.cxx')
-rw-r--r-- | Source/cmAddLibraryCommand.cxx | 80 |
1 files changed, 80 insertions, 0 deletions
diff --git a/Source/cmAddLibraryCommand.cxx b/Source/cmAddLibraryCommand.cxx index fd39eec02..cbc6ed1e9 100644 --- a/Source/cmAddLibraryCommand.cxx +++ b/Source/cmAddLibraryCommand.cxx @@ -43,6 +43,7 @@ bool cmAddLibraryCommand // the type of library. Otherwise, it is treated as a source or // source list name. There may be two keyword arguments, check for them bool haveSpecifiedType = false; + bool isAlias = false; while ( s != args.end() ) { std::string libType = *s; @@ -76,6 +77,11 @@ bool cmAddLibraryCommand type = cmTarget::UNKNOWN_LIBRARY; haveSpecifiedType = true; } + else if(libType == "ALIAS") + { + ++s; + isAlias = true; + } else if(*s == "EXCLUDE_FROM_ALL") { ++s; @@ -96,6 +102,80 @@ bool cmAddLibraryCommand break; } } + if (isAlias) + { + if(!cmGeneratorExpression::IsValidTargetName(libName.c_str())) + { + this->SetError(("Invalid name for ALIAS: " + libName).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 \"" << libName + << "\" 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 \"" << libName + << "\" because target \"" << aliasedName << "\" does not already " + "exist."; + this->SetError(e.str().c_str()); + return false; + } + cmTarget::TargetType aliasedType = aliasedTarget->GetType(); + if(aliasedType != cmTarget::SHARED_LIBRARY + && aliasedType != cmTarget::STATIC_LIBRARY + && aliasedType != cmTarget::MODULE_LIBRARY + && aliasedType != cmTarget::OBJECT_LIBRARY) + { + cmOStringStream e; + e << "cannot create ALIAS target \"" << libName + << "\" because target \"" << aliasedName << "\" is not a library."; + this->SetError(e.str().c_str()); + return false; + } + if(aliasedTarget->IsImported()) + { + cmOStringStream e; + e << "cannot create ALIAS target \"" << libName + << "\" because target \"" << aliasedName << "\" is IMPORTED."; + this->SetError(e.str().c_str()); + return false; + } + this->Makefile->AddAlias(libName.c_str(), aliasedTarget); + return true; + } + + if(importTarget && excludeFromAll) + { + this->SetError("excludeFromAll with IMPORTED target makes no sense."); + return false; + } /* ideally we should check whether for the linker language of the target CMAKE_${LANG}_CREATE_SHARED_LIBRARY is defined and if not default to |