Silence custom command depending on CMAKE_VERBOSE_MAKEFILE

Michał Walenciak

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 not.

Is there a common way for doing this?

The one way I see is to redirect output to /dev/null depending on this CMake's flag, but what about Windows and other OSes?

Is there a portable or recommended way? What about default rules for C/C++ compiling commands?

SirDarius

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).

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How to Silence the read command

From Dev

RecordRTC with custom sample rate records silence

From Dev

Makefile: silence the "make[N]:" line specifically

From Dev

How do I silence an error in a makefile?

From Dev

How to silence unused command line argument error with clang without disabling it?

From Dev

How to silence unused command line argument error with clang without disabling it?

From Dev

How can I silence ALL output from a command in a batch file?

From Dev

execute bash command depending on keyword

From Dev

Run a sed command depending on a variable

From Dev

cmake add_custom_command and DEPENDS/TARGET

From Dev

CMake does not find custom command "ls"

From Dev

CMake bracket escape character for custom target command

From Dev

cmake does not copy file in custom command

From Dev

cmake add_custom_command not working

From Dev

CMake bracket escape character for custom target command

From Dev

CMake : Flex custom_command never called

From Dev

Custom authorization depending on user property

From Dev

CMake: execute a macro/function as the command of add_custom_command

From Dev

Variable argument in for loop changes depending on powershell command

From Dev

How to execute command on localhost depending on a remote host

From Dev

Execute a different command depending on the output of the previous

From Dev

Disable certain ListViewItem depending on custom property UWP

From Dev

MediaWiki Wiki Custom footer depending on category

From Dev

Sort array of custom objects depending on dynamic criterias

From Dev

Overwrite price depending custom options on Magento

From Dev

Static page with custom content depending on url

From Dev

How to call a CMake function from add_custom_target/command?

From Dev

cmake: add_custom_command only invoked first time

From Dev

Cmake: add_custom_command argument based on variable content

Related Related

  1. 1

    How to Silence the read command

  2. 2

    RecordRTC with custom sample rate records silence

  3. 3

    Makefile: silence the "make[N]:" line specifically

  4. 4

    How do I silence an error in a makefile?

  5. 5

    How to silence unused command line argument error with clang without disabling it?

  6. 6

    How to silence unused command line argument error with clang without disabling it?

  7. 7

    How can I silence ALL output from a command in a batch file?

  8. 8

    execute bash command depending on keyword

  9. 9

    Run a sed command depending on a variable

  10. 10

    cmake add_custom_command and DEPENDS/TARGET

  11. 11

    CMake does not find custom command "ls"

  12. 12

    CMake bracket escape character for custom target command

  13. 13

    cmake does not copy file in custom command

  14. 14

    cmake add_custom_command not working

  15. 15

    CMake bracket escape character for custom target command

  16. 16

    CMake : Flex custom_command never called

  17. 17

    Custom authorization depending on user property

  18. 18

    CMake: execute a macro/function as the command of add_custom_command

  19. 19

    Variable argument in for loop changes depending on powershell command

  20. 20

    How to execute command on localhost depending on a remote host

  21. 21

    Execute a different command depending on the output of the previous

  22. 22

    Disable certain ListViewItem depending on custom property UWP

  23. 23

    MediaWiki Wiki Custom footer depending on category

  24. 24

    Sort array of custom objects depending on dynamic criterias

  25. 25

    Overwrite price depending custom options on Magento

  26. 26

    Static page with custom content depending on url

  27. 27

    How to call a CMake function from add_custom_target/command?

  28. 28

    cmake: add_custom_command only invoked first time

  29. 29

    Cmake: add_custom_command argument based on variable content

HotTag

Archive