[CMake] Compiler flags for Obj-C++ files only

Allan Odgaard jovxhr102 at sneakemail.com
Wed May 21 16:16:56 EDT 2008


On 21 May 2008, at 21:52, Bill Hoffman bill.hoffman-at-kitware.com | 
CMake| wrote:

> E. Wing wrote:
>> I believe the answer is no. I think Sean McBride and I brought this  
>> up
>> before and agree with you that we need a case like this. The bug is
>> filed here:
>> http://public.kitware.com/Bug/view.php?id=4756
>> Please feel free to add additional information (or submit a patch :))
>> On 5/21/08, Allan Odgaard <jovxhr102 at sneakemail.com> wrote:
>>> I need to set a compiler flag for Obj-C++ files (-fobjc-call-cxx-
>>> cdtors).
>>>
>>> Setting it for C++ will give a warning from gcc when the source file
>>> type is C++ (instead of Obj-C++).
>>>
>>> Is there any way to set flags for only Obj-C++ files?
>>
>
> You could use a source file property compile flag as a work around.


Yes, though I have 15+ targets so I ended up replacing all uses of  
ADD_LIBRARY/EXECUTABLE with MY_ADD_LIBRARY/EXECUTABLE and have it do  
the following before calling the real function:

   FOREACH(SRC ${ARGN})
     IF("${SRC}" MATCHES "\\.mm$")
       SET_SOURCE_FILES_PROPERTIES("${SRC}" PROPERTIES COMPILE_FLAGS "- 
fobjc-call-cxx-cdtors")
     ENDIF()
   ENDFOREACH()

Thanks all for the prompt replies.



More information about the CMake mailing list