Skip to content

Diagnose object library self-reference

Ben Boeckel requested to merge ben.boeckel/cmake:objlib-own-target-objs into master

The code

add_library(A OBJECT a.c)
target_sources(A PRIVATE $<TARGET_OBJECTS:A>)

used to crash CMake via infinite recursion while evaluating the generator expression. Then the change in !677 (merged) avoided the infinite recursion because GetKindedSources now creates a map entry and initializes it once. If it is called again on the same target during that initialization, the partially computed results are returned. This is still wrong but does not crash. Detect and diagnose this case instead.

Fixes: #16578 (closed)

Edited by Brad King

Merge request reports