[CMake] portable way of linking (external) libs statically/dynamically/for dlopen
Alexander Neundorf
a.neundorf-work at gmx.net
Mon Apr 29 16:36:46 EDT 2013
On Monday 29 April 2013, Philippe Cerfon wrote:
> Hi.
>
> I've always thought one of the main objectives of cmake was being
> portable, right?
> So I was looking for a way to let the user (i.e. the person building a
> project) choose how he wan't to link each external library (i.e. not
> the ones built as targets by my project), depending on what that lib
> supports and (when my own code supports it:) dynamically loaded via
> e.g. dlopen.
>
> But it seems that I cannot even tell CMake (in a portable way) that it
> should use static or dynamic linking for some external lib (not to
> talk about the core libs like libc or libstdc++).
> Of course I can work around this any manually search for e.g. .so and
> .a files... but that woudln't be portable anymore... not to talk about
> different linkage options per linker... so ideally CMake should (IMHO)
> take care of all this (for each supported platform/linker).
>
>
> Am I missing something? Or is that just som major deficiency in the
> portable-part?
If cmake finds the static version of the library, it should properly use that
one.
Making cmake find the static version instead of the dynamic version is kind of
hard, AFAIK the only way to do this is to give the full filename of the static
lib.
Alex
More information about the CMake
mailing list