No support for Mach-O mh_object targets
Currently CMake doesn't support Mach-O mh_object targets (as near as I can tell).
I understand that CMake has its own object library target, which makes sense in many development use cases. But there are times when building a mh_object target is unavoidable.
I'd go into examples, but they probably aren't relevant. Suffice it to say that I cannot avoid building an mh_object target in our CMake project.
What I've done to work around this issue up till now is to create a custom command that echos out an object file list from object library targets using the $<TARGET_OBJECTS:obj_lib_name> generator pattern, then calling clang++ to create the mh_object target.
While this has worked in the past, it's now broken because we're trying to make a universal binary version of x86_64 and arm64 for Apple Silicon. We now see this error when configuring:
Error evaluating generator expression: $<TARGET_OBJECTS:mylib_obj> The evaluation of the TARGET_OBJECTS generator expression is only suitable for consumption by CMake (limited under Xcode with multiple architectures). It is not suitable for writing out elsewhere.
I understand the nature of this message. But in fact for Xcode targets, I think it's not accurate because we actually can access the paths to the universal binary objects because the architecture env var is part of the path.
Right or wrong though, I'm stuck. I'd be happy to completely abandon this approach if mh_object targets were supported directly.
Failing that, I need some way to access the paths to universal objects in CMake object library targets that I can use to build up my own link command.
Thanks in advance for any resolution suggestions.