Files
CMake/Tests/RunCMake/FileAPI/codemodel-v2-data/targets/c_object_exe.json
Brad King a833aa1167 Fix dependencies on targets linked through object libraries
When an object library is used via `target_link_libraries`, any targets
listed in the object library's `INTERFACE_LINK_LIBRARIES` closure should
become direct dependencies of the consuming target.  However, these were
accidentally left out by `cmComputeTargetDepends::CollectTargetDepends`
because object libraries are encountered through external object sources
first and then added to the `emitted` set which blocks them from being
processed as link dependencies.

This was not noticed by the test case in commit bab24e782c
(target_link_libraries: Propagate dependencies of object libraries,
2018-12-10, v3.14.0-rc1~260^2) because the relevant dependency appears
transitively through the object library target itself.

Re-order the logic to process link dependencies first, and then external
object sources.  That way object libraries used via
`target_link_libraries` will be treated as such by dependency analysis.

This also adds missing backtrace information for object libraries used
via `target_link_libraries`.  The missing information was mentioned in a
FIXME comment in the RunCMake.FileAPI test added by commit ea0a060168
(fileapi: Add test for codemodel v2, 2018-11-09, v3.14.0-rc1~257^2~7).
That comment itself was dropped by commit a0de350e2f (FileAPI test:
Break gen_check_targets() into JSON files, 2020-02-07), but we can now
update the corresponding location in the `.json` files to have the
now-expected backtrace information.

Fixes: #20421
2020-03-04 13:07:41 -05:00

155 lines
4.4 KiB
JSON

{
"name": "c_object_exe",
"id": "^c_object_exe::@5ed5358f70faf8d8af7a$",
"directorySource": "^object$",
"projectName": "Object",
"type": "EXECUTABLE",
"isGeneratorProvided": null,
"sources": [
{
"path": "^empty\\.c$",
"isGenerated": null,
"sourceGroupName": "Source Files",
"compileGroupLanguage": "C",
"backtrace": [
{
"file": "^object/CMakeLists\\.txt$",
"line": 6,
"command": "add_executable",
"hasParent": true
},
{
"file": "^object/CMakeLists\\.txt$",
"line": null,
"command": null,
"hasParent": false
}
]
},
{
"path": "^.*/Tests/RunCMake/FileAPI/codemodel-v2-build/object/.*/empty(\\.c)?\\.o(bj)?$",
"isGenerated": true,
"sourceGroupName": "Object Libraries",
"compileGroupLanguage": null,
"backtrace": [
{
"file": "^object/CMakeLists\\.txt$",
"line": 7,
"command": "target_link_libraries",
"hasParent": true
},
{
"file": "^object/CMakeLists\\.txt$",
"line": null,
"command": null,
"hasParent": false
}
]
}
],
"sourceGroups": [
{
"name": "Source Files",
"sourcePaths": [
"^empty\\.c$"
]
},
{
"name": "Object Libraries",
"sourcePaths": [
"^.*/Tests/RunCMake/FileAPI/codemodel-v2-build/object/.*/empty(\\.c)?\\.o(bj)?$"
]
}
],
"compileGroups": [
{
"language": "C",
"sourcePaths": [
"^empty\\.c$"
],
"includes": null,
"defines": null,
"compileCommandFragments": null
}
],
"backtrace": [
{
"file": "^object/CMakeLists\\.txt$",
"line": 6,
"command": "add_executable",
"hasParent": true
},
{
"file": "^object/CMakeLists\\.txt$",
"line": null,
"command": null,
"hasParent": false
}
],
"folder": null,
"nameOnDisk": "^c_object_exe(\\.exe)?$",
"artifacts": [
{
"path": "^object/((Debug|Release|RelWithDebInfo|MinSizeRel)/)?c_object_exe(\\.exe)?$",
"_dllExtra": false
},
{
"path": "^object/((Debug|Release|RelWithDebInfo|MinSizeRel)/)?c_object_exe\\.pdb$",
"_dllExtra": true
}
],
"build": "^object$",
"source": "^object$",
"install": {
"prefix": "^(/usr/local|[A-Za-z]:.*/codemodel-v2)$",
"destinations": [
{
"path": "bin",
"backtrace": [
{
"file": "^object/CMakeLists\\.txt$",
"line": 13,
"command": "install",
"hasParent": true
},
{
"file": "^object/CMakeLists\\.txt$",
"line": null,
"command": null,
"hasParent": false
}
]
}
]
},
"link": {
"language": "C",
"lto": null,
"commandFragments": null
},
"archive": null,
"dependencies": [
{
"id": "^c_object_lib::@5ed5358f70faf8d8af7a$",
"backtrace": [
{
"file": "^object/CMakeLists\\.txt$",
"line": 7,
"command": "target_link_libraries",
"hasParent": true
},
{
"file": "^object/CMakeLists\\.txt$",
"line": null,
"command": null,
"hasParent": false
}
]
},
{
"id": "^ZERO_CHECK::@5ed5358f70faf8d8af7a$",
"backtrace": null
}
]
}