# add\_custom\_target COMMAND and star \* bypass shell expansion

**URL:** <https://discourse.cmake.org/t/add-custom-target-command-and-star-bypass-shell-expansion/11250>\
**Category:** Code\
**Created:** [July 14, 2024, 3:40pm UTC](https://discourse.cmake.org/t/add-custom-target-command-and-star-bypass-shell-expansion/11250 "2024-07-14T15:40:13Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![MM77](https://discourse.cmake.org/user_avatar/discourse.cmake.org/mm77/32/2002_2.png) [@MM77](https://discourse.cmake.org/u/MM77)\
**Post date:** [July 14, 2024, 3:40pm UTC](https://discourse.cmake.org/t/add-custom-target-command-and-star-bypass-shell-expansion/11250/1 "2024-07-14T15:40:13Z")

</div>

I create a list of arguments to pass to the COMMAND of add\_custom\_target

```auto
list(APPEND MyOdbArgs "--default-pointer")
list(APPEND MyOdbArgs "*")

```

the makefile generated contains snippet like

`cd /home/.../<proj>-build-release-sqlite/odb && odb -d sqlite --std c++17 --profile boost --default-pointer * --other options`

odb is then invoked but the shell does expand the star and messes the up odb invocation.

I then tried

```auto
list(APPEND MyOdbArgs "--default-pointer")
list(APPEND MyOdbArgs "\*")

```

with the same result

FInally I tried

```auto
list(APPEND MyOdbArgs "--default-pointer")
list(APPEND MyOdbArgs "\\*")

```

the invocation then is

`cd /home/.../<proj>-build-release-sqlite/odb && odb -d sqlite --std c++17 --profile boost --default-pointer \* --other options`

and odb gets given actually ‘\*’ as a arg which it doesn’t accept.

all 3 times, VERBATIM is used.

When I copied the odb invocation from the build.make file generated by cmake and pasted manually, the backslash start mechanism works for odb.

Any ideas how get the character \* to reach odb as is?

---

<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:** [July 14, 2024, 11:18pm UTC](https://discourse.cmake.org/t/add-custom-target-command-and-star-bypass-shell-expansion/11250/2 "2024-07-14T23:18:49Z")

</div>

CMake doesn’t guarantee that any particular shell is used, or even that a shell is used at all. If you need to rely on shell features, put the command you want to run in a shell script file and run from `execute_process()` instead.
