[CMake] XCode: Detect debug build to enable /D_Debug or similar?

Michael Wild themiwi at gmail.com
Fri Nov 25 09:52:51 EST 2011


On 11/25/2011 03:40 PM, g4 at novadsp.com wrote:
[ Fixed TOFU ]
> On 24/11/2011 22:22, Michael Hertling wrote:
>> On 11/24/2011 07:08 PM, g4 at novadsp.com wrote:
>>> How can I do this? Specifically generating for XCode.
>>>
>>> My cmakefile has this:
>>>
>>> if (${CMAKE_CFG_INTDIR} STREQUAL "Debug")
>>> Message("We are generating/building debug code for ${this_target}")
>>> ADD_DEFINITIONS(/D_DEBUG)
>>> endif()
>>>
>>> But _DEBUG is never defined.
>>>
>>> This question comes up twice on StackOverflow. Both answers are
>>> endlessly mutually referential ...
>>>
>>> Thx++
>>
>> SET_DIRECTORY_PROPERTIES(PROPERTIES COMPILE_DEFINITIONS_DEBUG _DEBUG)
>>
>> Regards,
>>
>> Michael
>
> I forgot to aks - what is the recommended way of adding multiple
> definitions? i.e. /D_DEBUG /D_NO_GZIP?
> 
> Thx++
> 

set_directory_properties(PROPERTIES
  COMPILE_DEFINITIONS_DEBUG "_DEBUG;_NO_GZIP")

Either using quotes and semicolon-separated list as above, or use the
set_property command:

set_property(DIRECTORY PROPERTY
  COMPILE_DEFINITIONS_DEBUG _DEBUG _NO_GZIP)


Michael


More information about the CMake mailing list