[cmake-developers] Support for imported targets in CMAKE_REQUIRED_LIBRARIES

Alexander Neundorf neundorf at kde.org
Sun Jan 29 11:37:42 EST 2012


On Monday 23 January 2012, Brad King wrote:
> On 1/21/2012 5:58 PM, Alexander Neundorf wrote:
> > To get the link line I moved code from
> > cmLocalGenerator::OutputLinkLibraries() into a separate function
> > GetLinkLine(cmTarget, cmComputeLinkInformation).
> 
> > But before I get there I get a segfault:
> [snip]
> 
> > It crashes in cmTarget::ComputeLinkClosure() because
> > mTarget::GetLinkImplementation() returns 0 for imported targets. It
> > probably should not get there at all, since calling GetLinkerLanguage()
> > always leads to that path.
> 
> The OutputLinkLibraries method is in generators so it is meant only for
> handling targets that are built in the project.  It is not written to
> work for imported targets.

I got there because you recommended:
"Then the implementation of the command can evaluate the "libs..." arguments
in a context where imported targets are known.  Loop over each library.
For those that this->Makefile->FindTargetToUse() returns a target, verify
that it is IMPORTED, and then call target->GetLinkInformation(config),
where config is the try-compile's configuration.  The return value of
that will be a cmComputeLinkInformation object from which you can query
the link line."

Did I misunderstand what you wrote ?

I had a further look, an cmTarget::GetLinkInterface() and 
cmTarget::ImportedGetFullPath() look liek I could iterate over them and build 
something from them.
But probably that logic is already somewhere.
Can you give me some pointers ?

Thanks
Alex



More information about the cmake-developers mailing list