[CMake] question on removing compiler flags

Philip Lowman philip at yhbt.com
Tue Jun 5 11:02:42 EDT 2007


We added the "/Za" (disable language extensions) flag to our compile 
flags and we're trying to find a way to remove it selectively on a per 
project basis since some Windows code needs language extensions to 
compile properly.

The REMOVE_DEFINITIONS() documentation states:

"Removes flags from command line of C and C++ compilers. This command 
can be used to remove any flag from a compile line, but the -D flag is 
accepted most C/C++ compilers."

This appears a bit ambiguous and makes it seem that you can use 
REMOVE_DEFINITIONS() to modify any compile flags.  This doesn't appear 
to work at least with Visual Studio 7 generated VCproj files.

We're currently experimenting with modifying the compiler flags variable 
using STRING(REGEX REPLACE...).  Does anyone know if there is an easier 
way to remove compiler flags on a per target or per source file basis?

-- 
Philip Lowman
Simulation Development Engineer, Modeling and Simulation Technology
General Dynamics Land Systems
http://www.gdls.com


More information about the CMake mailing list