-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use add_halide_generator() everywhere in apps/ #6554
Conversation
Existing CMake code uses add_executable + target_link_libraries to create a Generator, but the somewhat-recently-added add_halide_generator() helper is a cleaner way to do this. Move to using it everywhere in apps/ instead. (Note that add_halide_generator()) doesn't yet work for in-tree builds, unfortunately.)
We currently disable deprecation warnings inside Halide. This re-enables them there, and also inside add_halide_generator(). (Note, additive to PR #6554)
apps/bilateral_grid/CMakeLists.txt
Outdated
@@ -13,7 +13,7 @@ find_package(Halide REQUIRED) | |||
|
|||
# Generator | |||
add_halide_generator(bilateral_grid.generator SOURCES bilateral_grid_generator.cpp) | |||
target_link_libraries(bilateral_grid.generator PRIVATE Halide::Tools) | |||
target_link_libraries(bilateral_grid::halide_generators::bilateral_grid.generator PRIVATE Halide::Tools) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this actually work? I thought you couldn't set properties through aliases (and for imported targets, PRIVATE
makes no sense)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
...I thought that's what you wanted me to do.
I thought the whole point of this was to make it work for crosscompiling. The if TARGET
approach won't because there apparently won't be a non-decorated version of the library in that case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm sorry, I must not have explained well. if (TARGET ${unqualified_name})
is the correct way to check if you're in the host-build scenario, which is the one that matters if you're going to set build options on ${unqualified_name}
, like which libraries to link to the generator executable.
- In the host build scenario, these targets exist:
${unqualified_name}
is a normal CMake target that will create an executable. It is linked toHalide::Generator
by default.${qualified_name}
is anALIAS
target to${unqualified_name}
.
- In the cross-build scenario, this target exists:
${qualified_name}
is anIMPORTED
target that points to the executable in the host build.${unqualified_name}
does not exist.
In the cross-build, you are specifically importing the host-built tools. Since they have already been built, it does not make sense to set build properties on them.
I didn't re-add Halide::Tools to anything that didn't require it for compilation. My guess is that we had a lot that were adding it from copy-paste codegen. |
Now that this is merged, we should actually try cross-compiling some of these. |
Existing CMake code uses add_executable + target_link_libraries to create a Generator, but the somewhat-recently-added add_halide_generator() helper is a cleaner way to do this. Move to using it everywhere in apps/ instead.
(Note that add_halide_generator()) doesn't yet work for in-tree builds, unfortunately.)