Bug?: Link options get lost when adding a generator expression in a post build step

Last week I ran into a weird issue, which I think is a bug in CMake (but the instructions for reporting bugs state to first validate that it is not expected behavior on the Discourse).

We had a custom function that adds a post build step which calls the size tool from the toolchain and puts the results in a specific format so that our CI pipeline can gather these metrics as well.
I wanted to extend this with some information from the linker script, so I figured I’d just pass the link options to the CMake script I run in the post build step as well to find the location of the linker script (using a generator expression, as this custom function was often called directly after add_executable and configuration for that target would still be added afterwards as well).
This worked well, but suddenly our CI pipeline failed when it tried to run one of the compiled binaries on the target hardware.

After investigation, it turned out that, despite the fact that I only touched a post build step in my pull request, the compiled binary had changed significantly.
Removing the generator expression I added, give me the same binary as before.
Further investigation turned out that somehow CMake is dropping link options (e.g. INTERFACE_LINK_OPTIONS) when using the generator expression.

With the help of an LLM, I analyzed our code base and made a small example project that reproduces the behavior, which can be found here: Arno Moonen / bug-cmake-link-options-genex · GitLab

I really think this is a bug, given that I would think that a POST_BUILD command should never influence the options for the executable that is being build.