View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0004756CMakeCMakepublic2007-04-02 16:542016-06-10 14:30
ReporterSean McBride 
Assigned ToKitware Robot 
PrioritynormalSeverityfeatureReproducibilityalways
StatusclosedResolutionmoved 
PlatformOSOS Version
Product Version 
Target VersionFixed in Version 
Summary0004756: CMake needs an Objective-C equivalent of CMAKE_CXX_FLAGS
DescriptionCMake provides CMAKE_CXX_FLAGS and CMAKE_C_FLAGS to supply compiler flags that are only supported by C++ and C respectively.

It is however lacking an analogous feature for Objective-C. That is, we need a CMAKE_OBJC_FLAGS.

In many cases, gcc on Mac OS X actually gives a warning when a flag is passed when compiling for a language that does not support the flag. For example, the '-fobjc-gc' flag if passed when building C++ warns:

"cc1plus: warning: command line option "-fobjc-gc" is valid for ObjC/ObjC++ but not for C++"

Objective-C files can be recognised by the .m filename extension.

There is also Objective-C++, recognised by the .mm extension, that allows both C++ and Obj-C syntax in the same file. In this case, we could either have a CMAKE_OBJCXX_FLAGS or apply both CMAKE_CXX_FLAGS and CMAKE_OBJC_FLAGS to those files. I believe I prefer the latter, but I have not given it too much thought.
TagsNo tags attached.
Attached Files

 Relationships

  Notes
(0007072)
Eric Wing (reporter)
2007-04-02 17:09

Actually, I think you would need both/separate CMAKE_OBJC_FLAGS and CMAKE_OBJCXX_FLAGS. The problem is that there are some Obj-C++ only flags such as -fobjc-call-cxx-cdtors (Run non-trivial default constructors and destructors on C++ instance variables of Objective-C classes). This one is critical if you have C++ ivars (not pointers to) contained in an Obj-C class. But it is meaningless to pure C/Obj-C and pure C++ code.


(0007909)
Sean McBride (reporter)
2007-06-19 13:48

Eric, you are quite right, CMake does need both.
(0009718)
Sean McBride (reporter)
2007-11-21 11:11

In VTK, if one enables Garbage Collection in Cocoa, one gets many warnings:

http://www.vtk.org/Testing/Sites/RogueResearch4/Mac10.5-VTKBS-dbg/20071121-0300-Nightly/BuildWarning.html [^]
(0009978)
Sean McBride (reporter)
2007-12-18 10:34

Committed a workaround for the VTK case, to eliminate all the warnings when doing a GC build of VTK Cocoa:

/cvsroot/VTK/VTK/Rendering/CMakeLists.txt,v <-- CMakeLists.txt
new revision: 1.267; previous revision: 1.266
(0021244)
Sean McBride (reporter)
2010-07-05 15:34

Just to ping this bug.... Nothing much has changed as of 2.8.2. I'd still like to see this supported.
(0028019)
Brad King (manager)
2011-12-20 08:41

Should all C flags be used for ObjC too, and C++ flags for ObjC++?

I think the real change needed here may be to split ObjC and ObjCXX out into their own languages that need to be enabled by the project() or enable_language() commands. Then they will be fully distinct and can have their own compiler flags and such. Achieving this with compatibility though will require a policy:

  http://www.cmake.org/Wiki/CMake/Policies [^]
(0028022)
Eric Wing (reporter)
2011-12-20 12:17

Obj-C is a pure 100% superset of C. It seems reasonable that C flags be used for ObjC.
I think it is safe to extend that idea for C++ to ObjC++.

I am having trouble imagining a real world case where you would not want the flags passed on.
(0028023)
Sean McBride (reporter)
2011-12-20 15:38

I concur with Eric here...
(0028146)
David Cole (manager)
2012-01-03 13:43

This seems like a large amount of work for a very small benefit. Is there anybody listening in on this issue who can supply a patch, including, but not limited to the following:

- adding new languages ObjC and ObjCXX
- adding new flags for the languages
- associating *.m and *.mm files with the languages
- creating a policy
- adding a test
- following up on the dashboard when things go wrong on various Mac submissions

Anybody have time to work on a patch?
(0028147)
Brad King (manager)
2012-01-03 14:23

Re 0004756:0028146: I think the discussion here has concluded that we do not need new languages ObjC and ObjCXX but can instead just add the extra flags for *.m and *.mm sources with a special case. The simplest generalization of the special case I can think of is to define "variants" of a language that get special flags.
(0041351)
Kitware Robot (administrator)
2016-06-10 14:27

Resolving issue as `moved`.

This issue tracker is no longer used. Further discussion of this issue may take place in the current CMake Issues page linked in the banner at the top of this page.

 Issue History
Date Modified Username Field Change
2007-11-21 11:11 Sean McBride Note Added: 0009718
2007-12-18 10:34 Sean McBride Note Added: 0009978
2010-07-05 15:34 Sean McBride Note Added: 0021244
2011-12-20 08:41 Brad King Note Added: 0028019
2011-12-20 12:17 Eric Wing Note Added: 0028022
2011-12-20 15:38 Sean McBride Note Added: 0028023
2012-01-03 13:43 David Cole Note Added: 0028146
2012-01-03 14:23 Brad King Note Added: 0028147
2014-02-14 14:09 Brad King Assigned To Bill Hoffman => Steve Wilson
2014-02-14 14:09 Brad King Target Version => CMake 3.1
2014-10-03 09:33 Brad King Assigned To Steve Wilson =>
2014-10-03 09:33 Brad King Status assigned => backlog
2014-10-03 09:33 Brad King Target Version CMake 3.1 =>
2016-06-10 14:27 Kitware Robot Note Added: 0041351
2016-06-10 14:27 Kitware Robot Status backlog => resolved
2016-06-10 14:27 Kitware Robot Resolution open => moved
2016-06-10 14:27 Kitware Robot Assigned To => Kitware Robot
2016-06-10 14:30 Kitware Robot Status resolved => closed


Copyright © 2000 - 2018 MantisBT Team