Introduce HalideFeatures system for optional components #8384
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.
Previously, our
option()
declarations were scattered and not well documented. They certainly weren't self-documenting. Some of them depended on other options and used various ways to handle conflicts. Sometimes inconsistencies were handled with fatal errors, other times by silently overriding an option.With this PR, I introduce a new
Halide_feature
function that is designed to handle interdependent options and default initialization in a much more regular way.It behaves very much like option in its first three parameters:
Halide_feature(CMAKE_FLAG "documentation string" DEFAULT_VALUE)
Only now
DEFAULT_VALUE
can be more intelligent than simplyON
orOFF
. It can also beTOP_LEVEL
, which isON
iffCMAKE_PROJECT_TOP_LEVEL
is true. It can also beAUTO
which isON
iff theDEPENDS
clause is defined and true. For example,If a feature is set to
ON
but itsDEPENDS
clause is false, a warning will be issued and the feature will be forcedOFF
in the cache.Furthermore, these features register their documentation strings with the built-in
FeatureSummary
system so now instead of a stream of easy-to-miss messages, the configuration ends with a summary of what is enabled and disabled:A feature may be marked as
ADVANCED
, which excludes it from the feature summary unless the log level is set to verbose. It also marks it as advanced in the cache, which hides it from the default view in the CMake GUI and the curses-TUI.Finally, features are computed early in the build so that subdirectories see a consistent view. Some generator tests that were broken under static Halide (meaning no autoschedulers) are now properly skipped by directly checking
WITH_AUTOSCHEDULERS
.