[cmake-developers] wlink command-line parsing

Brad King brad.king at kitware.com
Wed Mar 26 15:04:36 EDT 2014


On 03/26/2014 02:45 PM, Jiri Malak wrote:
> For unix like system cmdl is reconstruct from argv by aproximation one
> space as separator between each item. Next is processed as characters stream.

Thanks, that is the explanation I needed.  Is that done on Windows too?

Here is an experiment in bash with spaces in the object file names:

$ for arg in file {'s 1.obj' 's 2.obj' 's 3.obj'} ; do echo "[$arg]"; done
[file]
[{s 1.obj]
[s 2.obj]
[s 3.obj}]

The wlink-reconstructed string will then be

 file {s 1.obj s 2.obj s 3.obj}

The shell consumed the single quotes so wlink will not see them.
This is what I meant in my "'/path with space/to/src.o'" example.
The two-layer quoting is needed to ensure wlink sees the single
quotes:

$ for arg in file {"'s 1.obj'" "'s 2.obj'" "'s 3.obj'"} ; do echo "[$arg]"; done
[file]
[{'s 1.obj']
['s 2.obj']
['s 3.obj'}]

The wlink-reconstructed string will then be

 file {'s 1.obj' 's 2.obj' 's 3.obj'}

and wlink will see the single quotes.

Therefore the proposed useSingleQuote API changes in CMake are not
correct.  Instead the object names themselves should each be
single-quoted before being sent through the normal double-quoting
for link command-line generation.

Does an invocation of wlink on Windows handle

 file {"'s 1.obj'" "'s 2.obj'" "'s 3.obj'"}

correctly when launched from a command prompt?

Thanks,
-Brad




More information about the cmake-developers mailing list