[CMake] Imported libraries lookup

Brad King brad.king at kitware.com
Wed Apr 22 10:41:28 EDT 2009


Sergey Rudchenko wrote:
> What piece of code should handle those imported targets? I thought it is
> cmMakefile::AddLinkLibraryForTarget, but it doesn't do that. Should a
> local generator check itself whether a library is an imported target?
> I thought this work is done transparently for generators.

Imported targets are kept in cmMakefile::ImportedTargets which is separate
from regular targets.  The generators do not see them when looping over
lists of targets.  The cmMakefile::AddLinkLibraryForTarget method just
adds the target name to a list of libraries to be linked.  This list gets
transformed by cmComputeLinkDepends and cmComputeLinkInformation into the
final link line, which includes lookup of imported targets.

> I use cmLocalVisualStudio6Generator as a reference and looked at the
> cmLocalUnixMakefileGenerator3 but still do not understand how to distinguish
> imported link libraries from other ones in a LocalGenerator.

In general the generators should never have to see any imported targets.
If you have a "cmTarget*" you can always ask its IsImported() method.

> Now I'm working in the CVS source.

Great, thanks.

-Brad


More information about the CMake mailing list