# Escaping for variable content in a add\_custom\_command

**URL:** <https://discourse.cmake.org/t/escaping-for-variable-content-in-a-add-custom-command/11700>\
**Category:** Code\
**Created:** [September 16, 2024, 10:59pm UTC](https://discourse.cmake.org/t/escaping-for-variable-content-in-a-add-custom-command/11700 "2024-09-16T22:59:35Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![pboettch](https://discourse.cmake.org/user_avatar/discourse.cmake.org/pboettch/32/216_2.png) [@pboettch](https://discourse.cmake.org/u/pboettch)\
**Post date:** [September 16, 2024, 10:59pm UTC](https://discourse.cmake.org/t/escaping-for-variable-content-in-a-add-custom-command/11700/1 "2024-09-16T22:59:35Z")

</div>

The following CMakeLists.txt:

```auto
cmake_minimum_required(VERSION 3.30)
project(ProjectName)

set(F "Test with spaces and (parens)")

add_custom_target(t ALL COMMAND doit ${F})

```

Generate the folloing command line:

```auto
doit Test\ with\ spaces\ and\ (parens)

```

As we can see, spaces are correctly escaped, but not the parentheses? Why is that so?

---

<div class="post-metadata">

**Author:** ![craig.scott](https://discourse.cmake.org/user_avatar/discourse.cmake.org/craig.scott/32/20_2.png) [@craig.scott](https://discourse.cmake.org/u/craig.scott)\
**Post date:** [September 17, 2024, 7:22am UTC](https://discourse.cmake.org/t/escaping-for-variable-content-in-a-add-custom-command/11700/2 "2024-09-17T07:22:31Z")

</div>

Add the `VERBATIM` keyword to your `add_custom_target()` call. That should handle escaping more robustly, but I don’t know off-hand if it handles parentheses for your case.
