How to add a dependency on a compiler plugin

I left out POST_BUILD, not sure if that matters. I think it should be on the plugin target too, not the simple target. I updated my example accordingly.

Another thing to try is to make that custom command produce an output that the simple target depends on. That would be the add_custom_command(OUTPUT somefile ...) form. Or maybe try BYPRODUCTS with my earlier example. I’m shooting in the dark a bit here, I don’t recall the exact condition that blocks the optimisation, but I’m pretty sure it relates to custom commands somehow. I wasn’t able to find the posts about it when I went looking before, sorry.