[cmake-developers] portable way for linking (single) libraries statically or dynamically

Christoph Anton Mitterer calestyo at scientia.net
Tue Apr 3 21:41:04 EDT 2012


Hi.

I recently brought this up at cmake[0] and bill encouraged me to forward
some parts here.


I'd like if CMake was more abstract and frees me from fiddling around
with compiler/platform specific stuff in many cases.
One (and which I consider very basic) for which this is missing is the
selection whether single libraries (including the basic ones, libc,
libstd++, the loader) are linked statically or dynamically.
This should be selectable per lib.
Reasons are found in the thread at [0].

A syntactical way to do (at least for the non base libs) this was
perhaps something like:
target_link_library(target <[STATIC|DYNAMIC] lib+>* )
If STATIC DYNAMIC is omitted, the compiler default (typically dynamical)
or another global CMake default is used.

* = 0 to many
+ = 1 to many
<> logical brackets
[] = optional
| = OR


I spend some more thought on CMake and what I like and dislike[1].
In case you're interested have a look[2].



Cheers,
Chris.


[0] http://www.cmake.org/pipermail/cmake/2012-April/049773.html
[1] Actually the list of the dislikes is much bigger, but don't take
this personally... it's just useless to largely write about the many
things that are already perfect :) ).
[2] https://plus.google.com/102329811815220905914/posts/TQsy1WQroJ9
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 5677 bytes
Desc: not available
URL: <http://public.kitware.com/pipermail/cmake-developers/attachments/20120404/175c9c75/attachment-0002.bin>


More information about the cmake-developers mailing list