Use name with spaces for TARGET qmake variable

I am experimenting with custom QGC build and came across an issue that I am unable to resolve. I changed TARGET to be “Custom QGC” - basically there is a space in the TARGET. This causes the post link build setup (QGCSetup.pri) to fail on MacOS as cp command fails to copy files due to the space character in TARGET. On Mac, cp (from QMAKE_COPY_DIR) needs the space in path to be escaped by a backslash. I tried using $$replace() to add escape character but that did not help. What would be the correct way of handling spaces in TARGET without having to make many changes to QGCSetup.pri? Any input is greatly appreciated! Thanks.

Actually I found a typo in my $$replace command, and it actually works after I fixed the typo. So following is my solution, and I would greatly appreciate any comment about if this is the correct way.

In QGCSetup.pri, I modified the first MacBuild block as below

MacBuild {
    TARGET = $$replace(TARGET_ORIG, " ", "\ ")

Then I added the following line to the end of the last MacBuild block


Essentially I temporarily added the escape character to TARGET variable if it contained spaces, and then restored TARGET to original once build setup was completed. I am not yet sure if temporarily modifying TARGET has any repercussions. Everything seems to work without any issues. Thanks!

I have been finding more things as I keep learning details about qmake. I found a better solution that what I was using in the comment above. Instead of temporarily escaping TARGET, I now use $$shell_quote to get correct paths that use TARGET variable with spaces in it.