[CMake] Figuring out dependencies for a library in order to build

E. Wing ewmailing at gmail.com
Sat Jul 16 07:27:41 EDT 2005


I'm trying to write Find_X.cmake modules for some libraries I depend
on. However, these libraries are a bit more complicated than what I'm
used to dealing with because they potentially depend on other
libraries. The problem is the dependencies the main library has can
vary depending on how it was compiled, which is information I don't
know ahead of time. I would like to write a Find cmake module that can
figure out which dependencies are needed to allow my program to
compile.

As a concrete example, SDL_sound represents one of these libraries I'm
trying to write a module for. SDL_sound is a decoder library and
unified interface for some popular sound formats. To support
additional formats, SDL_sound may dynamically link against a variety
of different libraries. This is where my problem begins. When I move
from computer to computer, distro to distro, platform to platform,
every system may have a differently built SDL_sound. So for example,
SDL_sound might link to Ogg Vorbis on one system, but not on another
system. Another example is that SDL_sound might link to MikMod for
.mod support on one system, but links to ModPlug for .mod support on
another system, and a third system might actually link to both MikMod
and ModPlug.

In order for my program which uses SDL_sound to successfully build, I
must also explicitly link against all the libraries that SDL_sound
depends on with compilers like gcc. I think with Visual Studio, I may
have managed to build without these explicit links, but my memory
might be playing tricks on me. So I would like to be able to figure
out the minimal set of dependencies I need to allow my stuff to build.

Is there a way I can accomplish this with CMake? Are there any
examples of this I can look at?

Thanks,
Eric


More information about the CMake mailing list