[cmake-developers] NMake and trailing directory separators in custom commands?

Johan Björk phb at spotify.com
Wed Jan 26 04:48:20 EST 2011


I didn't try using VERBATIM, but since it fails even when having an
extra slash for the WORKING_DIRECTORY parameter, I'm not sure if it
would help.

In my case it was not required, but for copying files, it can make a difference.

cp file foo/bar <- creates the file bar, or copies into the directory
bar if it exists
cp file foo/bar/ <- fails if bar does not exist.

I can't even imagine what anyone would be using the current behavior
for, it would only concatenate two following COMMAND invocations...

/Johan

On Tue, Jan 25, 2011 at 7:27 PM, Brad King <brad.king at kitware.com> wrote:
> On 01/25/2011 12:35 PM, Johan Björk wrote:
>> Hi everyone,
>>
>> I just started using the NMake generator, and ran into an issue that
>> is probably trivial to fix for someone who knows the generator code.
>> If one of the steps for the makefile contains a trailing directory
>> separator, it will escape the newline and result in an invalid
>> command.
>>
>> ie (Untested, just wrote something up that should reproduce)
>>
>> ADD_CUSTOM_COMMAND(OUTPUT foo COMMAND cmake -E copy file
>> ${CMAKE_CURRENT_LIST_DIR}/a.c ${CMAKE_BINARY_DIR}/foo/bar/). CMake
>> will correctly escape all the unix newlines to '\', but also the last
>> one, which results in NMake treating the next line as part of the
>> command.
>>
>> Not very familiar with either Windows nor NMake, so I don't know what
>> the correct fix is.. Add an extra space if the last character is a \ ?
>
> I didn't think we translated custom command arguments like that because
> we don't know if they are strings or paths.  Our CustomCommand test
> verifies that all kinds of strings make it through correctly, at least
> with the VERBATIM option to add_custom_command.
>
> -Brad
>



More information about the cmake-developers mailing list