[CMake] Compiler definitions for shared and static builds

Louis Hoefler louis.hoefler at gmx.de
Mon Jan 31 11:18:58 EST 2011


Hello everyone,
I try to generate a cmake project and want to
build shared and dynamic libraries in one step.

I therefore added two targets:
ADD_LIBRARY(${fox_default_libname} STATIC ${fox_cpp_files} 
${fox_h_files} icons.h icons.cpp)
ADD_LIBRARY(${fox_default_libname} SHARED ${fox_cpp_files} 
${fox_h_files} icons.h icons.cpp)

Booth of them should have different compiler definitions.
How to set them explicitly for shared and static targets?

I tried something like this:
SET_PROPERTY(TARGET ${fox_default_libname}
                            PROPERTY COMPILE_DEFINITIONS 
${fox_default_defines_static}
)

But the targets for shared and static builds need to have different names
(becouse the need different build directories though).

Is there an elegant way to achive what I want?

Thank you, Louis Hoefler



More information about the CMake mailing list