[Cmake] Adding compile flags in several steps

Martin Magnusson martin.magnusson at aass.oru.se
Tue Aug 17 08:18:30 EDT 2004


I'd like to specify a set of compiler flags which should always be used, 
and another set which should be appended under certain circumstances. I 
tried doing it like this:

SET_SOURCE_FILES_PROPERTIES(
   ${SOURCES}
   COMPILE_FLAGS "-Wall -Werror")

IF(DEBUG_MODE)
   SET_SOURCE_FILES_PROPERTIES(
     ${SOURCES}
     COMPILE_FLAGS "-g -O0 -DDEBUG_MODE=1" )
   MESSAGE("Debug build.")
ELSE(DEBUG_MODE)
   SET_SOURCE_FILES_PROPERTIES(
     ${SOURCES}
     COMPILE_FLAGS "-O3 -DDEBUG_MODE=0" )
   MESSAGE("Release build.")     	
ENDIF(DEBUG_MODE)

but then, the "-Wall -Werror" is always overwritten. What's the correct 
way to do this?

/ martin


More information about the Cmake mailing list