[CMake] preprocessor definitions seem to fail... (Visual Studio)

James Bigler bigler at cs.utah.edu
Thu Aug 23 10:06:57 EDT 2007


Maik Keller wrote:
> Hello,
> 
> I discovered another problem in my project:
> 
> I need some preprocessor definitions which I usually create in a Visual Studio project by myself. Now, I tried to do it with cmake but it obviously has no effect, which means I am not able to compile my project.
> 
> This is what I already tried (VCC is my preprocessor definition):
> 
> SET_TARGET_PROPERTIES(${LIB_NAME} PROPERTIES DEFINE_SYMBOL "VCC")
> 
> or:
> 
> SET_TARGET_PROPERTIES(${LIB_NAME} PROPERTIES COMPILE_FLAGS "VCC")
> 
> Where is my mistake?

I usually use ADD_DEFINITIONS(-DVCC).  I'm not sure if Visual Studio 
understands -D defines, but try this.

Also, you may want to use SET_SOURCE_PROPERTIES on the sources instead 
of the TARGET if you want to set this for only certain source files.

See the documentation for further information on these commands.  I use 
"cmake --help-full | less" on cygwin.  You can do this in cmd (cmake.exe 
is installed with the other stuff), but I don't know of a good pager for 
window's command.

James


More information about the CMake mailing list