This is not possible with CMake and therefore a missing feature .
The answer from Tarydon in the question you are referring to is setting up exactly what you want - the " Custom Build Step ". This means that you still only have your main goal (VS Project), with something that looks like a " Post-construction event ", but technically it is not, because events after assembly do not fire if the project is updated.
The answer from tpg2114 works, but has one major drawback; this is spam of your decision with fake projects. If you have one hundred projects in the solution, you need to add another hundred, as well as post-build wrappers in the first hundred, of course, it is undesirable.
Depending on your situation, it can sometimes be easier to use Post-Build Events and force a rebuild of at least one source file so that the project is actually created and therefore also runs your user command.
source share