CMake needs an Objective-C equivalent of CMAKE_CXX_FLAGS
This issue was created automatically from an original Mantis Issue. Further discussion may take place here.
CMake 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.