[CMake] Toggling a Preprocessor macro for targets within a single project

Eric Noulard eric.noulard at gmail.com
Fri Feb 20 04:41:01 EST 2009


2009/2/20 Andreas Pokorny <andreas.pokorny at gmail.com>:
> Hi,
> We have a platfrom abstraction layer which uses a trace system. But
> one of the trace backends also uses the platform abstraction for
> network communication. So we want to build the required platform libs
> twice with and without tracing. Now I thought I can do the following
> with cmake:
>
> PROJECT(PaltformLib)
>
> FILE(GLOB SOURCES .....)
>
> ADD_DEFINITIONS(-DUSE_TRACER)
> ADD_LIBRARY(PlatformLib STATIC ${SOURCES})

May be it would be easier to use the DEFINE_SYMBOL property on the
library target?

SET_TARGET_PROPERTIES(PlatformLib PROPERTIES
                                             DEFINE_SYMBOL USE_TRACER)

Then you shouldn't have to ADD_DEFINITIONS and REMOVE_DEFINITIONS?


-- 
Erk


More information about the CMake mailing list