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

Andreas Pokorny andreas.pokorny at gmail.com
Fri Feb 20 04:32:50 EST 2009


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})

REMOVE_DEFINITIONS(-DUSE_TRACER)
ADD_LIBRARY(PlatformLib_no_tracing STATIC ${SOURCES})

ADD_DEFINITIONS(-DUSE_TRACER)

With verbose Makefiles I can see that USE_TRACER ist defined for both tragets.


kind regards
Andreas


More information about the CMake mailing list