I am using generated files in my cmake project. I have a script that generates source code from some input, and the same script can also validate the input, if given a different command line argument, like this:
generate_code.py --generate
generate_code.py --validate
The --validate
mode will print errors to stdout
if the input is not valid, and I would like to have those errors visible. My current setup is to run with --validate
in an execute_process
and with --generate
in an add_custom_command
. This works, but doesn't print the user-friendly error messages from the --validate
mode when the input changes, because the execute_process
doesn't run again.
What would be the best way to surface these errors? If I could force execute_process
to always run, that would work, or if I could capture stdout
when --generate
fails and surface that, I could modify the --generate
option to print friendly error messages, and then display them. How can I do one or both of those?