[CMake] shared + static object creation in one CMakeLists.txt

Alexander Neundorf a.neundorf-work at gmx.net
Mon Jan 21 19:26:37 EST 2008


On Tuesday 22 January 2008, Steffen Wendzel wrote:
> hi,
>
> I'm new on cmake and tried it for the 2nd time this day. I want to
> build both: a static and a shared object from my code and tried it
> this way:
>
> ADD_LIBRARY(cmle SHARED
>         src/libcmle.C
>         src/libcmle_int.C
> )
>
> ADD_LIBRARY(cmle STATIC
>         src/libcmle.C
>         src/libcmle_int.C
> )
>
> But this didn't work, only the shared object was created. What
> went wrong?

You created two targets with the same name, this isn't supported.

Do something like this:

ADD_LIBRARY(cmle_SHARED SHARED ...)
SET_TARGET_PROPERTIES(cmle_SHARED PROPERIES ... OUTPUT_NAME cmle)

ADD_LIBRARY(cmle_STATIC STATIC ...)
SET_TARGET_PROPERTIES(cmle_STATIC PROPERIES ... OUTPUT_NAME cmle)

Are you actually sure you need to build both versions ?

Bye
Alex


More information about the CMake mailing list