Skip to content

Conversation

@alexreinking
Copy link
Member

@alexreinking alexreinking commented Aug 9, 2024

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 simply ON or OFF. It can also be TOP_LEVEL, which is ON iff CMAKE_PROJECT_TOP_LEVEL is true. It can also be AUTO which is ON iff the DEPENDS clause is defined and true. For example,

Halide_feature(WITH_TEST_RUNTIME "Build runtime tests" AUTO
               DEPENDS NOT MSVC)

If a feature is set to ON but its DEPENDS clause is false, a warning will be issued and the feature will be forced OFF 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:

-- The following features have been enabled:

 * Halide_ENABLE_EXCEPTIONS, Enable exceptions in Halide
 * Halide_ENABLE_RTTI, Enable RTTI in Halide
 * WITH_AUTOSCHEDULERS, Build the Halide autoschedulers
 * WITH_PACKAGING, Halide's CMake package install rules
 * WITH_PYTHON_BINDINGS, Halide's native Python module (not the whole pip package)
 * WITH_SERIALIZATION, Include experimental Serialization/Deserialization code
 * WITH_TESTS, Halide's unit test suite
 * WITH_TUTORIALS, Halide's tutorial code
 * WITH_UTILS, Optional utility programs for Halide, including HalideTraceViz
 * WITH_TEST_AUTO_SCHEDULE, Build autoscheduler tests
 * WITH_TEST_CORRECTNESS, Build correctness tests
 * WITH_TEST_ERROR, Build error tests
 * WITH_TEST_WARNING, Build warning tests
 * WITH_TEST_PERFORMANCE, Build performance tests
 * WITH_TEST_GENERATOR, Build generator tests
 * WITH_TEST_RUNTIME, Build runtime tests

-- The following features have been disabled:

 * WITH_DOCS, Halide's Doxygen documentation
 * WITH_TEST_FUZZ, Build fuzz tests

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.

Copy link
Contributor

@steven-johnson steven-johnson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

@alexreinking alexreinking merged commit 7b53a88 into main Aug 9, 2024
@alexreinking alexreinking deleted the build/features-system branch August 9, 2024 22:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants