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

Mike Jackson imikejackson at gmail.com
Thu Aug 23 10:13:41 EDT 2007



On Aug 23, 2007, at 10:06 AM, James Bigler wrote:

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

Take a look at:

http://predef.sourceforge.net/precomp.html#sec32

It looks like you are trying to decide in your code if the Visual  
studio compiler is being used. Look at the web link and use those  
defines. Microsoft is defining those so they will always be defined  
on Visual Studio compilations. Less you have to put in your CMakeFile.

And, yes, Cmake will translate the ADD_DEFINITIONS(-DVCC) into the  
correct command on visual studio.

-- 
Mike Jackson   Senior Research Engineer
Innovative Management & Technology Services


More information about the CMake mailing list