I\'ve a custom command in my CMake script which generates a lot of output. I\'d like to take advantage of CMAKE_VERBOSE_MAKEFILE so I can decide if I want to see this output or
Technically speaking, CMAKE_VERBOSE_MAKEFILE
exists for the purpose of hiding and showing command lines, not command output.
If I had to do this, I would use a custom variable.
But on the main topic, here is how you should do:
if (COMMAND_VERBOSE)
execute_process(COMMAND "mycustom_command")
else (COMMAND_VERBOSE)
execute_process(COMMAND "mycustom_command" OUTPUT_QUIET)
endif (COMMAND_VERBOSE)
This is the most portable way to do so.
There is also an ERROR_QUIET
flag, however it is a bad idea to disable error messages, else the user would be unable to see why the command failed if it failed.
If you are using add_custom_command
or add_custom_target
instead, such a flag does not exist.
You'll have to provide a manual redirection to /dev/null
(Unix), or NUL
(Windows).