Xcode: Mixed C/OBJC or CXX/OBJCXX targets contain only CMAKE_{C,CXX}_FLAGS, not CMAKE_{OBJC,OBJCXX}_FLAGS
I will use c and objc, but the exact same is true of cxx and objcxx.
In xcode the flags for a target are put in 'other c flags'. There are no objective-c specific flags. Using cmake, if you have a target with mixed c/objc then the flags will be the c flags only, the ones from the objc are ignored.
This is surprising if you set e.g. string (APPEND CMAKE_OBJC_FLAGS " -fobjc-arc")
and then your project fails to build. I attach a minimal reproduction case.
The logic is around here https://gitlab.kitware.com/cmake/cmake/-/blob/v3.17.3/Source/cmGlobalXCodeGenerator.cxx#L2263
Possible improvements:
- Detect that this case is happening and report a warning ('mixed objc/c target detected, objc flags will be ignored in xcode generator')?
- Concat and dedup the c and objc flags before putting in the xcode project?
Workaround is to set relevant OBJC flags in the C language aswell.
Edited by Harry Mallon