0

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?

Iancovici
  • 5,574
  • 7
  • 39
  • 57
  • 1
    I don't think that CMake supports running command on the build stage even if another command fails. E.g. [Make doesn't support that](https://stackoverflow.com/questions/21118020/can-gnu-make-execute-a-rule-whenever-an-error-occurs). Just create your own script, which internally executes `make` and then calls `python.exe genReport.py`. – Tsyvarev Nov 13 '21 at 14:40
  • didn't seem to work, am i doing this right? add_custom_target(run COMMAND make -j COMMAND python.exe genReport.py ) – Iancovici Nov 13 '21 at 18:57
  • No, I mean a non-CMake script, e.g. a shell one, or a python. And instead of running `make` for build the project, you could run that additional script. – Tsyvarev Nov 13 '21 at 19:55
  • @Tsyvarev, that's an acceptable answer. Thanks for identifying cmake limitation, I've moved forward with a batchscript to launch make with stderr redirected to a text file, and follow up summarizing python script – Iancovici Nov 14 '21 at 12:45

0 Answers0