Skip to content

Commit

Permalink
Add argument to add_halide_library for header name.
Browse files Browse the repository at this point in the history
  • Loading branch information
alexreinking committed Apr 7, 2021
1 parent 9f441f1 commit a914e5e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
15 changes: 11 additions & 4 deletions README_cmake.md
Expand Up @@ -805,6 +805,7 @@ add_halide_library(<target> FROM <generator-target>
[GRADIENT_DESCENT]
[C_BACKEND]
[REGISTRATION OUTVAR]
[HEADER OUTVAR]
[<extra-output> OUTVAR])
extra-output = ASSEMBLY | BITCODE | COMPILER_LOG | CPP_STUB
Expand Down Expand Up @@ -869,10 +870,16 @@ compiler on a generated source. Note that a `<target>.runtime` target is _not_
created in this case, and the `USE_RUNTIME` option is ignored. Other options
work as expected.

If `REGISTRATION` is set, the path to the generated `.registration.cpp` file
will be set in `OUTVAR`. This can be used to generate a runner for a Halide
library that is useful for benchmarking and testing, as documented above. This
is equivalent to setting `-e registration` at the generator command line.
If `REGISTRATION` is set, the path (relative to `CMAKE_CURRENT_BINARY_DIR`)
to the generated `.registration.cpp` file will be set in `OUTVAR`. This can be
used to generate a runner for a Halide library that is useful for benchmarking
and testing, as documented above. This is equivalent to setting
`-e registration` at the generator command line.

If `HEADER` is set, the path (relative to `CMAKE_CURRENT_BINARY_DIR`) to the
generated `.h` header file will be set in `OUTVAR`. This can be used with
`install(FILES)` to conveniently deploy the generated header along with your
library.

Lastly, each of the `extra-output` arguments directly correspond to an extra
output (via `-e`) from the generator. The value `OUTVAR` names a variable into
Expand Down
5 changes: 4 additions & 1 deletion cmake/HalideGeneratorHelpers.cmake
Expand Up @@ -48,7 +48,7 @@ function(add_halide_library TARGET)
##

set(options C_BACKEND GRADIENT_DESCENT)
set(oneValueArgs FROM GENERATOR FUNCTION_NAME NAMESPACE USE_RUNTIME AUTOSCHEDULER ${EXTRA_OUTPUT_NAMES})
set(oneValueArgs FROM GENERATOR FUNCTION_NAME NAMESPACE USE_RUNTIME AUTOSCHEDULER HEADER ${EXTRA_OUTPUT_NAMES})
set(multiValueArgs TARGETS FEATURES PARAMS PLUGINS)
cmake_parse_arguments(ARG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})

Expand Down Expand Up @@ -143,6 +143,9 @@ function(add_halide_library TARGET)
# Always emit a C header
set(GENERATOR_OUTPUTS c_header)
set(GENERATOR_OUTPUT_FILES "${TARGET}.h")
if (ARG_HEADER)
set(${${ARG_HEADER}} "${TARGET}.h" PARENT_SCOPE)
endif ()

# Then either a C source, a set of object files, or a cross-compiled static library.
if (ARG_C_BACKEND)
Expand Down

0 comments on commit a914e5e

Please sign in to comment.