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

Brad King brad.king at kitware.com
Tue Jan 25 13:27:35 EST 2011


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