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

Bill Hoffman bill.hoffman at kitware.com
Thu Aug 23 10:17:32 EDT 2007


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.
-D works, and CMake will find the -D stuff and convert it to the correct 
settings in a vcproj file when creating vs ide projects.
(BTW, -D has worked for every c/C++ compiler I have ever seen...)

-Bill



More information about the CMake mailing list