Xcode: No support for Relocatable Object File targets + TARGET_OBJECTS genex problem
I need to generate a Relocatable Object File target in an Xcode project. CMake has support for OBJECT targets, but these are basically static libraries where the list of objects are available as a generator expression (like $<TARGET_OBJECTS:libname>) to other targets.
I tried to make a custom target that calls 'ld' directly to produce the relocatable object file, but this doesn't work because when the TARGET_OBJECTS genex is invoked, it evaluates the $(PROJECT_NAME) env var incorrectly so the path to the objects is not correct.
I suspect that this path issue is due to the fact that we're generating a top level project as well as sub projects. When building, the top level project name is used so the objects are compiled into a path with the top level project name as a directory component, but when evaluating the TARGET_OBJECTS genex, the subproject name is used.
After many work around attempts, I think I'm left with the following possible alternatives:
- Stop generating subprojects. I've verified that this works.
- Fix the output paths of the $<TARGET_OBJECTS:libname>, replacing the sub project name directory component with the top level project name.
- Post process the generated project to create a real Relocatable Object File target. I've verified that I can start with a generated static library target and convert it to a Relocatable Object File, but it's kind of hacky.