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

Erik van der Wal kireputsje at dochmarwat.nl
Fri Oct 15 13:29:36 EDT 2004


Dear list,

When compiling a project which always seemed to work under VC6, We ran 
into a problem when using VS.NET 2003.
I stripped the files to a simple version. Compilation gives the 
following errors.

\dev\cmake\test.cpp(2) : error C2124: divide or mod by zero
\dev\cmake\test.cpp(2) : warning C4067: unexpected tokens following 
preprocessor directive - expected a newline
\dev\cmake\test.cpp(2) : warning C4067: unexpected tokens following 
preprocessor directive - expected a newline

I tracked this down to the following define:
#if SOME_DEFINE

Which is expanded to something like:
#if 1/Yu"test.h"

When examining the test.vcproj.cmake, I noticed:
SOME_DEFINE=1 /Yu"test.h",

Seems like ADD_DEFINITIONS only allows -D options?

My question, is this a bug?
If no, how should I do it?
If yes, how to work around this problem?

Regards, Erik van der Wal.
(Using XP and Cmake 2.0.3)


-------- CMakeLists.txt --------
PROJECT( test )
ADD_DEFINITIONS( -DSOME_DEFINE=1 )
ADD_DEFINITIONS( /Yu"test.h" )
ADD_EXECUTABLE( test test.cpp )
-------- end --------

-------- test.cpp --------
int main(void) {
#if SOME_DEFINE
    return 0;
#else
    return 1;
#endif
}
-------- end --------



More information about the CMake mailing list