[CMake] question on removing compiler flags

Pau Garcia i Quiles pgquiles at elpauer.org
Tue Jun 5 11:46:50 EDT 2007


Quoting Philip Lowman <philip at yhbt.com>:

> 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?

This might be non-sensical depending on what your CMakeLists.txt do  
and your needs but here come my two cents: have you tried to do the  
oppossite thing (add the definition only when it is needed)?



More information about the CMake mailing list