Skip to content

Conversation

@steven-johnson
Copy link
Contributor

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.)

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.)
steven-johnson added a commit that referenced this pull request Jan 12, 2022
We currently disable deprecation warnings inside Halide. This re-enables them there, and also inside add_halide_generator().

(Note, additive to PR #6554)
# 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)
Copy link
Member

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)

Copy link
Contributor Author

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.

Copy link
Member

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 to Halide::Generator by default.
    • ${qualified_name} is an ALIAS target to ${unqualified_name}.
  • In the cross-build scenario, this target exists:
    • ${qualified_name} is an IMPORTED 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.

@steven-johnson
Copy link
Contributor Author

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.

@steven-johnson steven-johnson merged commit b9e0e72 into master Jan 13, 2022
@steven-johnson steven-johnson deleted the srj/addgen branch January 13, 2022 04:35
@alexreinking
Copy link
Member

Now that this is merged, we should actually try cross-compiling some of these.

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