How to run a post build script in CMAKE, regardless if any object fails?

I’m trying to generate a compiler error and warning report post-build. This is all in a CMake Environment.

So I created a script, and tied to executable post-build.

add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
   COMMAND python.exe genReport.py"
)

however this won’t execute if not all STATIC Librarys are generated, because then the executable can’t link them.

So I thought now I needed to create call same custom command post-build per library.

However, we also create objects before Libraries, and objects can’t have a post build command.

All I’m trying to do is always run a script at the end of a make all. Whether executable is built, or any library fails, or any object fails to compile.

Is there a way to always run a post build script?

make and ninja (nor any of the IDE generators) do not provide a way to execute a command on a failure, so I don’t know how CMake would actually make this happen.