How to traverse `target_link_libraries` dependencies in the file api?

I’m using cmake 3.26.3. I have three targets A, B, and C. And I have target_link_libraries(A PRIVATE B PUBLIC C). I use the file api and traverse to the codemodel object for target A, and it’s dependencies field is completely missing. It’s not even set to an empty list, the key just isn’t present in the codemodel target object. If I look at the includes field for the compileGroups, then I do see lots of entries like:

{
    "backtrace" : 41,
    "path" : "some-include-dir"
},

And backtrace 41 points to a call to target_link_libraries. How do I get a target id from this? Reading the documentation it looks like it’s supposed to be in the dependencies field, but it isn’t.

Solved my own problem. If you have CMAKE_OPTIMIZE_DEPENDENCIES=ON, then dependencies are not represented in the cmake file api output. I feel like this should be documented, it’s pretty subtle and definitely not obvious.

That sounds like a bug to me. Would you mind reporting it in CMake’s issue tracker?