XCODE_DEPEND_HELPER seems broken when there are few OBJECT libraries in hierarchy with subprojects
My environment: CMake: 3.16.2 Xcode: 11.3.1 OS: MacOS Mojave 10.14.6
I have main project which includes subproject. Subproject has next hierarchy of libraries:
# OBJECT-1 ---> STATIC--\
# |---> SHARED
# OBJECT-2 -------------/
When I try to generate project with Xcode generator and then build it causes linking error because STATIC library is missing. Project example is attached: test_xcode_fail.zip
I configure and build it with following commands:
mkdir build && cd build
cmake .. -GXcode
cmake --build . --target shared_lib
And I got error:
clang: error: no such file or directory: '../build/subproject/Debug/libstatic_lib_dependency.a'
When I investigated problem I noticed that CMake generates two XCODE_DEPEND_HELPER.make files.
One is build/CMakeScripts/XCODE_DEPEND_HELPER.make
and another is build/subproject/CMakeScripts/XCODE_DEPEND_HELPER.make
They both are invoked with script build/subproject/CMakeScripts/object_lib_dependency2_postBuildPhase.makeDebug
script with parameter PostBuild.object_lib_dependency2.Debug
.
Both files XCODE_DEPEND_HELPER.make are almost the same and differ only by paths to OBJECT-x libraries:
...
- build/subproject/test_xcode_fail_subproject.build/Debug/object_lib_dependency1.build/libobject_lib_dependency1.a
+ build/subproject/test_xcode_fail.build/Debug/object_lib_dependency1.build/libobject_lib_dependency1.a
...
- build/subproject/test_xcode_fail_subproject.build/Debug/object_lib_dependency2.build/libobject_lib_dependency2.a
+ build/subproject/test_xcode_fail.build/Debug/object_lib_dependency2.build/libobject_lib_dependency2.a
...
But object libraries seem always appear only by paths:
build/subproject/test_xcode_fail.build/Debug/object_lib_dependency2.build/libobject_lib_dependency2.a
build/subproject/test_xcode_fail.build/Debug/object_lib_dependency1.build/libobject_lib_dependency1.a
So STATIC library is always removed which leads to the issue.
I would appreciate if you may suggest how to avoid the issue without changing hierarchy until bug get fixed.
Update: I found option CMAKE_XCODE_GENERATE_TOP_LEVEL_PROJECT_ONLY, but setting it on leads to compilation error:
make[1]: build/subproject/CMakeScripts/XCODE_DEPEND_HELPER.make: No such file or directory
make[1]: *** No rule to make target `build/subproject/CMakeScripts/XCODE_DEPEND_HELPER.make'. Stop.
make: *** [object_lib_dependency1_buildpart_1] Error 2
Reported as separated bug