[CMake] problem: using options other than -D with VS.NET

Erik van der Wal kireputsje at dochmarwat.nl
Fri Oct 15 14:03:06 EDT 2004


Brad King wrote:

> Erik van der Wal wrote:
>
>> Seems like ADD_DEFINITIONS only allows -D options?
>
> That is correct.  The command is called ADD_DEFINITIONS, not 
> ADD_FLAGS.  Implementing it to take the "-D" part explicitly was a bad 
> choice in hindsight because it allows the command to be abused to add 
> other flags.  This use of the command is not officially supported, 
> though.

According to the documentation:
"Adds flags to command line of C and C++ compilers. This command can be 
used to add any flag to a compile line, but the -D flag is accepted most 
C/C++ compilers. Other flags may not be as portable."

My interpretation is, that I can set any flag I like and it is passed to 
the compiler, but the compiler might not recognize it.
However it now seems like the flag is not even passed to the compiler. 
It is put in a wrong way in the test.vcproj.cmake.

Questions:
1) Could you rephrase the documentation?
"Adds definitions to command line of C and C++ compilers. This command 
can also be used to add any flag to the command line, but this will not 
work with all cmake generators. These flags may also not be as portable 
between C/C++ compilers."
2) Is is possible to change this .NET generator to only accept -D 
options, disregarding any other option? Preferably it should also give a 
warning message saying it did disregard some flags.
3) You did not state a workaround. Is SET_SOURCE_FILES_PROPERTIES the 
way to go?

Regards, Erik van der Wal.


More information about the CMake mailing list