OBJECT libraries fail if there are link cycles
I ran into a situation where I have two OBJECT libraries that are cyclically referencing each other. This throws an error, but it should be allowed (just as it's allowed for static libraries). The result should simply be the union of all the object files.
I've tried this with CMake 3.14.5.
Also there's a strange error about SOURCES using a generator expression that depends on itself.
$ cat CMakeLists.txt
cmake_minimum_required(VERSION 3.13)
project(Test C)
add_library(foo OBJECT foo.c)
add_library(bar OBJECT bar.c)
target_link_libraries(foo PUBLIC bar)
target_link_libraries(bar PUBLIC foo)
add_library(foobar STATIC)
target_link_libraries(foobar PUBLIC foo bar)
$ touch foo.c bar.c
$ cmake -G 'Unix Makefiles' .
CMake Error at CMakeLists.txt:4 (add_library):
The SOURCES of "foo" use a generator expression that depends on the SOURCES
themselves.
CMake Error: The inter-target dependency graph contains the following strongly connected component (cycle):
"foo" of type OBJECT_LIBRARY
depends on "bar" (strong)
"bar" of type OBJECT_LIBRARY
depends on "foo" (weak)
At least one of these targets is not a STATIC_LIBRARY. Cyclic dependencies are allowed only among static libraries.