[CMake] Recursive dependencies and static libraries
bill.hoffman at kitware.com
Wed Nov 5 21:05:25 EST 2008
Jed Brown wrote:
> On Wed 2008-11-05 23:02, Csaba Halász wrote:
>> Yes, I have just run into this very problem (see my earlier mail about libtiff)
>> I just made some try-compile tests to check for known possible dependencies.
>> I hoped somebody with more cmake experience could offer some insight,
>> but didn't get any responses yet.
> That's a coincidence, I hadn't read your message. My Tiff example was
> just the simplest case I could think of that exhibits this bug.
> The method you use is unfortunately exponential in the number of
> possible dependencies, an issue when N=40. When there is no other
> information available, perhaps a reasonable solution is a macro that
> checks for undefined symbols matching a regex. Is there a CMake way to
> interrogate an archive for undefined symbols (presumably just calling nm
> isn't recommended).
I am not sure CMake will ever get this correct by itself. Just because
there is an undefined symbol in a static lib does not mean it won't
work. It might be a system library. I don't think CMake should try to
find the missing libraries automatically as this would have to try all
libraries on a system. This just means a project should have a good
FindWhatEver.cmake that handles the known depends. If the project is
built by CMake, then a find_package config file can be created that has
this information. If you look at FindQt4, you can see CMake has the
ability to handle very complicated depend information in a Find script.
However, it will not come for free, someone is going to have to code
up that depend information.
There are several packages that deal with stuff like this, things like
pkg-config. They all rely on the developer of the package specifying
the depend information somewhere.
More information about the CMake