On 1/29/2012 11:37 AM, Alexander Neundorf wrote:
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 ?
My bad. I forgot that cmComputeLinkInformation won't work for imported
targets. You might be able to create a temporary target that pretends to
be in the project and use that to compute link information, but I do not
think CMake's internals will work like that out of the box.
Ideally a try_compile could be implemented by pretending that configuration
is complete and generating the try-compile target using the same generators
that would be used for the main project. Imagine if we could snapshot the
project configuration state, add the try-compile target, generate it, and
then roll back as if it never happened. Then imported targets would be
handled automatically. The try_compile could truly answer the question
"what would happen if I compiled *this* now?". I think a huge amount of
internal refactoring would be needed to achieve this though.
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 ?
It's in cmComputeLinkDepends and cmComputeLinkInformation which unfortunately
only work for non-IMPORTED targets.
You're running into the same can of worms I (now) remember running into
a few years ago when you first proposed handling imported targets with
try_compile. That's one reason it never got done. Let's just drop the
C++ side of this again. Your CMake-code-only solution is probably good
enough for typical use cases. Please refine that based on my original
comments and post again. I'm sorry for leading you on this goose chase.
-Brad
--
Powered by www.kitware.com
Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html
Please keep messages on-topic and check the CMake FAQ at:
http://www.cmake.org/Wiki/CMake_FAQ
Follow this link to subscribe/unsubscribe:
http://public.kitware.com/cgi-bin/mailman/listinfo/cmake-developers