[CMake] Imported libraries lookup

Brad King brad.king at kitware.com
Wed Apr 22 11:01:24 EDT 2009


Sergey Rudchenko wrote:
> On Wed, 2009-04-22 at 10:41 -0400, Brad King wrote:
>> In general the generators should never have to see any imported
>> targets.
>> If you have a "cmTarget*" you can always ask its IsImported() method.
> 
> Thanks, Brad. Now it's clean for we how things should be implemented.
> 
> So there is one straight problem for me: LocalGenerator uses
> cmTarget::GetLinkLibraries which is a
> std::vector<std::pair<std::string, LinkLibraryType> > >

Don't use GetLinkLibraries.  It's the "old-style" link computation results
which had some bugs.  If you're computing a set of libraries to specify
for linking in a project file, use cmComputeLinkInformation:

   cmComputeLinkInformation* pcli = target.GetLinkInformation(configName);

> So, I have no cmTarget* object there (and can't find it, since the
> cmMakefile::ImportedTargets is private). I guess there should be a
> method like:
> 
> cmTarget* cmMakefile::FindImportedTarget(const char* name);

   cmTarget* cmMakefile::FindTargetToUse(const char* name)

It looks for an imported target first, and then a standard target.

-Brad


More information about the CMake mailing list