Add OBJECT_LIBRARY target type

This library type can compile sources to object files but does not link
or archive them.  It will be useful to reference from executable and
normal library targets for direct inclusion of object files in them.

Diagnose and reject the following as errors:

* An OBJECT library may not be referenced in target_link_libraries.

* An OBJECT library may contain only compiling sources and supporting
  headers and custom commands.  Other source types that are not normally
  ignored are not allowed.

* An OBJECT library may not have PRE_BUILD, PRE_LINK, or POST_BUILD
  commands.

* An OBJECT library may not be installed, exported, or imported.

Some of these cases may be supported in the future but are not for now.

Teach the VS generator that OBJECT_LIBRARY targets are "linkable" just
like STATIC_LIBRARY targets for the LinkLibraryDependencies behavior.
This commit is contained in:
Brad King
2012-03-12 10:47:40 -04:00
parent d5aedf15a4
commit b87d7a60a0
12 changed files with 104 additions and 4 deletions
+10
View File
@@ -84,6 +84,16 @@ bool cmTargetLinkLibrariesCommand
return true;
}
if(this->Target->GetType() == cmTarget::OBJECT_LIBRARY)
{
cmOStringStream e;
e << "Object library target \"" << args[0] << "\" "
<< "may not link to anything.";
this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
cmSystemTools::SetFatalErrorOccured();
return true;
}
// but we might not have any libs after variable expansion
if(args.size() < 2)
{