Pau Garcia i Quiles wrote:
Quoting Philip Lowman <[EMAIL PROTECTED]>:

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


What we ended up doing was enabling the "/Za" flag globally and then on a per-library basis stripping the "/Za" from the CMAKE_CXX_FLAGS_* variables using STRING(REGEX REPLACE...) and adding it back for all files using SET_SOURCE_FILES_PROPERTIES() except the ones that absolutely need the language extensions.

Adding it manually to every library or source file would also have worked, but we didn't want to have to do this since we want our code to be as portable as possible without developers having to use SET_TARGET_PROPERTIES() on every target to add definitions like "/Za".

--
Philip Lowman
Simulation Development Engineer, Modeling and Simulation Technology
General Dynamics Land Systems
http://www.gdls.com
_______________________________________________
CMake mailing list
[email protected]
http://www.cmake.org/mailman/listinfo/cmake

Reply via email to