# Pass verbosity to custom/external commands? (ideally at build-time)

**URL:** https://discourse.cmake.org/t/pass-verbosity-to-custom-external-commands-ideally-at-build-time/4809
**Category:** Code
**Tags:** gen:makefiles
**Created:** [January 10, 2022, 11:42am UTC](https://discourse.cmake.org/t/pass-verbosity-to-custom-external-commands-ideally-at-build-time/4809 "2022-01-10T11:42:06Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![rcoup](https://discourse.cmake.org/user_avatar/discourse.cmake.org/rcoup/32/2091_2.png) [@rcoup](https://discourse.cmake.org/u/rcoup)
#### Post date: [January 10, 2022, 11:42am UTC](https://discourse.cmake.org/t/pass-verbosity-to-custom-external-commands-ideally-at-build-time/4809/1 "2022-01-10T11:42:06Z")

</div>

With `ExternalProject_Add`/`add_custom_command`/etc, what’s the best way to pass verbosity through as extra arguments?

Ideally increasing build-time verbosity via `make VERBOSE=1` or similar can also call `some command --verbose do` (while regular `make` calls `some command do`)… but `$<VERBOSE>` isn’t a valid generator expression.

Simplistically, a one-liner like:

```auto
ExternalProject_Add(foo
  ...
  BUILD_COMMAND some command $<$<BOOL:VERBOSE>:--verbose> do
  ...
)

```

`$<$<BOOL:${VERBOSE}>:--verbose>` works (configure-time), except that when it’s _not_ set you end up with `""` as an argument, which causes argument-parsing issues for the inner command.

How are others solving this cleanly? I know I can append to an arglist but it quickly gets unwieldy with many commands:

```auto
set(myBuildCommand some command)
if(VERBOSE)
  list(APPEND myBuildCommand --verbose)
endif()
list(APPEND myBuildCommand do)
ExternalProject_Add(foo
  ...
  BUILD_COMMAND ${myBuildCommand}
  ...
)

```

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)
#### Post date: [January 10, 2022, 4:56pm UTC](https://discourse.cmake.org/t/pass-verbosity-to-custom-external-commands-ideally-at-build-time/4809/2 "2022-01-10T16:56:17Z")

</div>

There’s no mechanism for this. Other build tools have no way to know that verbosity is asked for and CMake doesn’t offer a way to use build-time `make` variables.
