Scan generated export files to determine dependencies. #8385
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This module contains a system for declaring that an export file might depend on another CMake package that was found by find_package. Such dependencies are collected in a project-wide property (rather than a variable) along with a snippet of code that reconstructs the original call.
Then, after we have installed an export file via install(EXPORT), we can call a helper to add install rules that will read the file as-generated by CMake to check whether any of these packages could be required.
CMake does not like to expose this information, in part because generator expressions make computing the eventual link set undecidable. Even so, for our purposes if
Pkg::
appears in our link-libraries list, then we need to find_package(Pkg).This module implements that heuristic.
So why is this hard? It's because checking whether a dependency is actually included is very complicated. A library will appear if:
$<LINK_ONLY:${dep}>
There is an experimental feature in CMake 3.30 that will someday replace this module.
Some care is taken in the implementation to format the generated code. Here is an example of the code that is injected into
packaging/cmake_install.cmake
:And in the final
halide-static-deps.cmake
:These were produced by configuring with