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

David Cole david.cole at kitware.com
Tue Jan 25 12:53:16 EST 2011


On Tue, Jan 25, 2011 at 12:35 PM, Johan Björk <phb at spotify.com> 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 \ ?
>
> /Johan
>
> BTW: It also happens for WORKING_DIRECTORY.
> _______________________________________________
> cmake-developers mailing list
> cmake-developers at cmake.org
> http://public.kitware.com/cgi-bin/mailman/listinfo/cmake-developers
>

Can you eliminate the trailing slash? It's not required, is it? If it
is, certainly adding a space is an option.

Can we add a space ourselves in the generator? Or are there cases
where people are depending on the current behavior in some way.... Is
that possible, or just crazy thinking?


David



More information about the cmake-developers mailing list