[debhelper-devel] CMake, shared and static libraries

Nico Schlömer nico.schloemer at gmail.com
Wed Jun 18 08:48:11 UTC 2014


Hi everyone,

here's an oddity with debhelper and cmake that came to my mind the
other day, and I'd like to hear your opinion about it.

When building a project in CMake and you would like to build both
shared and static libraries, you have two options:
(1)  In the source code CMakeLists.txt, add two `add_library` calls, e.g.,
```
add_library(MyLib SHARED source1.c source2.c)
add_library(MyLibStatic STATIC source1.c source2.c)
```
(2) Don't touch the source code and build your software once with
`BUILD_SHARED_LIBS` set to `ON`, once with set to `OFF`.

In Debian, it's pretty common to want to have both static and shared
libraries built, and right now, you'll have to either patch the source
(bad) or fiddle around `debian/rules` to implement (2).

Is there a better way to handle things? Do you think (2) would be
worthwhile to have automated in debhelper?

Cheers,
Nico



More information about the debhelper-devel mailing list