[CMake] Problems with add_definitions()

Eric Noulard eric.noulard at gmail.com
Tue May 1 08:58:56 EDT 2007


2007/5/1, Christian Ehrlicher <Ch.Ehrlicher at gmx.de>:
> Hi,
>
> I want to build a static and a dynamic lib from the same sources. It's
> no problem until we need to export some functions :)
>
> // this defines MAKE_SOLID_LIB (with set_target_properties) so we can
> use dllexport
> kde4_add_library(solid SHARED ${solid_LIB_SRCS})
>
> // this defines nothing -> dllimport is assumed
> kde4_add_library(solid_static STATIC ${solid_LIB_SRCS})
>
> I can't use add_definitions(-DSOLID_EXPORT=) here because it's added for
> both libs. I also can't use set_target_properties with DEFINE_SYMBOL
> because this is ignored when building a static lib...
>
> Any ideas how to solve this?

Normally CMake already defines <libname>_EXPORTS for you
when compiling sources derived from:

ADD_LIBRARY(libname ${LIB_SRC})

May be you can just use this define?

I said "normally" because I did not find it in the CMake documentation
but we use it in our project.
-- 
Erk


More information about the CMake mailing list