[CMake] Linking hierarchy
Brad King
brad.king at kitware.com
Wed May 10 14:30:40 EDT 2006
svoboda at fi.muni.cz wrote:
> I'm using CMake in the following way:
What version of CMake are you using?
> - I create a simple shared library
> - The library requires many libraries during the built process
Please be more specific. Are the other libraries shared or static?
> - In the subdirectory (using the SUBDIRS command) I create examples,
> which are dependent on this shared library.
>
> What is the problem:
>
> - When building the examples in the subdirectory, all the required
> libraries are linked to these examples. I know, that these examples
> require only my shared library. Since CMake inherits linking
> dependencies I cannot avoid linking all the libraries, which were
> necessary when builing my library, to these simple examples.
The dependency chaining is necessary for static libraries on all
platforms and even shared libraries on some platforms.
My guess is that you are building static "convenience" libraries and
linking them together into a single shared library. This is not really
supported by CMake as it does not really make sense on all platforms (a
set of .lib archives on windows cannot be used to create a .dll). It
also does not work on most UNIX environments unless the objects in the
static archives are built with the -fPIC or equivalent flag.
What is your use case here? If the shared library provides everything
why can't you just build all the sources in one target?
-Brad
More information about the CMake
mailing list