summaryrefslogtreecommitdiffstats
path: root/Source/cmAddLibraryCommand.cxx
diff options
context:
space:
mode:
authorStephen Kelly <steveire@gmail.com>2012-11-02 14:47:40 (GMT)
committerBrad King <brad.king@kitware.com>2013-10-07 23:56:31 (GMT)
commitfe732264e9abb6249d1d112b24ce36b226590105 (patch)
tree97c08c00ec43b68f692d50729f536d84c7c0d13a /Source/cmAddLibraryCommand.cxx
parentd4134352abf69374fdad24d53d67734a135daaa5 (diff)
downloadCMake-fe732264e9abb6249d1d112b24ce36b226590105.zip
CMake-fe732264e9abb6249d1d112b24ce36b226590105.tar.gz
CMake-fe732264e9abb6249d1d112b24ce36b226590105.tar.bz2
Add the INTERFACE_LIBRARY target type.
This target type only contains INTERFACE_* properties, so it can be used as a structural node. The target-specific commands enforce that they may only be used with the INTERFACE keyword when used with INTERFACE_LIBRARY targets. The old-style target properties matching LINK_INTERFACE_LIBRARIES_<CONFIG> are always ignored for this target type. The name of the INTERFACE_LIBRARY must match a validity generator expression. The validity is similar to that of an ALIAS target, but with the additional restriction that it may not contain double colons. Double colons will carry the meaning of IMPORTED or ALIAS targets in CMake 2.8.13. An ALIAS target may be created for an INTERFACE library. At this point it can not be exported and does not appear in the buildsystem and project files are not created for them. That may be added as a feature in a later commit. The generators need some changes to handle the INTERFACE_LIBRARY targets returned by cmComputeLinkInterface::GetItems. The Ninja generator does not use that API, so it doesn't require changes related to that.
Diffstat (limited to 'Source/cmAddLibraryCommand.cxx')
-rw-r--r--Source/cmAddLibraryCommand.cxx30
1 files changed, 28 insertions, 2 deletions
diff --git a/Source/cmAddLibraryCommand.cxx b/Source/cmAddLibraryCommand.cxx
index cbc6ed1..130a033 100644
--- a/Source/cmAddLibraryCommand.cxx
+++ b/Source/cmAddLibraryCommand.cxx
@@ -82,6 +82,12 @@ bool cmAddLibraryCommand
++s;
isAlias = true;
}
+ else if(libType == "INTERFACE")
+ {
+ ++s;
+ type = cmTarget::INTERFACE_LIBRARY;
+ haveSpecifiedType = true;
+ }
else if(*s == "EXCLUDE_FROM_ALL")
{
++s;
@@ -151,7 +157,8 @@ bool cmAddLibraryCommand
if(aliasedType != cmTarget::SHARED_LIBRARY
&& aliasedType != cmTarget::STATIC_LIBRARY
&& aliasedType != cmTarget::MODULE_LIBRARY
- && aliasedType != cmTarget::OBJECT_LIBRARY)
+ && aliasedType != cmTarget::OBJECT_LIBRARY
+ && aliasedType != cmTarget::INTERFACE_LIBRARY)
{
cmOStringStream e;
e << "cannot create ALIAS target \"" << libName
@@ -249,6 +256,26 @@ bool cmAddLibraryCommand
}
}
+ std::vector<std::string> srclists;
+
+ if(type == cmTarget::INTERFACE_LIBRARY)
+ {
+ if (!cmGeneratorExpression::IsValidTargetName(libName)
+ || libName.find("::") != std::string::npos)
+ {
+ cmOStringStream e;
+ e << "Invalid name for INTERFACE library target: " << libName;
+ this->SetError(e.str().c_str());
+ return false;
+ }
+
+ this->Makefile->AddLibrary(libName.c_str(),
+ type,
+ srclists,
+ excludeFromAll);
+ return true;
+ }
+
if (s == args.end())
{
std::string msg = "You have called ADD_LIBRARY for library ";
@@ -258,7 +285,6 @@ bool cmAddLibraryCommand
cmSystemTools::Message(msg.c_str() ,"Warning");
}
- std::vector<std::string> srclists;
while (s != args.end())
{
srclists.push_back(*s);