POST_BUILD commands executed regardless target status if target is a custom one
When a command is attached to a target using add_custom_command(TARGET ... POST_BUILD...) and the target is a created with add_custom_target, the post build command is executed each time compilation is launched even if target is up to date.
If the target is a "native" one (i.e. library for example), the post build command is only executed if target is rebuilt.
Attached is a small CMakeLists.txt showing the issue:
- after generation and first build, files postbuild.txt and postbuild.custom.txt contains the string "POST BUILD"
- re-lauch compilation without changing anything. postbuild.txt is not changed, but postbuild.custom.txt contains now 2 lines "POST BUILD"
Tests done on Linux using cmake 3.9 using "Unix Makefiles" and Ninja generatorsCMakeLists.txt.