[CMake] Add a compiler switch to a a specific configuration

Brad King brad.king at kitware.com
Tue Jul 11 11:29:24 EDT 2006


Sagnes, Frederic wrote:
> Hello,
> 
> I'm using the STLport library on several targets on my project, and need to define the _STLP_DEBUG flag on the debug configuration of each target. I looked at :
> SET_TARGET_PROPERTIES ( PROPERTIES COMPILE_FLAGS -D_STLP_DEBUG )
> 
> ... but it doesn't seem to be able to specify a switch for a specific configuration, neither can :
> ADD_DEFINITIONS ( -D_STLP_DEBUG )
> 
> I hope there is a function that can do that, or a foreach trick.

Set the CMAKE_CXX_FLAGS_DEBUG variable:

SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -D_STLP_DEBUG")

or just put

#if !defined(NDEBUG) && !defined(_STLP_DEBUG)
# define _STLP_DEBUG
#endif

in a top-level header that is included before all STL headers.

-Brad


More information about the CMake mailing list