I tried two hours to pass an argument with a space to execute_process, but I didn’t find out how to do it. Cmake performs some magic quoting (“VERBATIM”). I tried using variables, various escaping, but I could not get it done.
My use case is quite simple: I would like to get a path without the last dir:
STRING(REGEX REPLACE /dir.*/ "x" PATH ${CMAKE_SOURCE_DIR}")
this does not work since it is always “greedy” and “/tmp/dir/src/dir” returns “tmpx” instead “/tmp/dir/srcx”. So I tried using some
Yes, but I forgot to mention that in my case it normally is not the last component that I want to be removed, but all up to one with a specific name, let’s say “rootdir”: /tmp/prj1/rootdir/src/legacystuff/prjold/rootdir/src/something → /tmp/prj1/rootdir/src/legacystuff/prjold/
and the old bash script used path="${path%/rootdir/*}".
Ohh thank you!
Indeed! It is so simple! I was sure this was exactly what I tried first! I must have been made another mistake.