add_custom_target COMMAND and star * bypass shell expansion

I create a list of arguments to pass to the COMMAND of add_custom_target

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

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

with the same result

FInally I tried

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?

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.