View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0015200CMakeCMakepublic2014-10-09 08:242015-04-06 09:07
ReporterRay Donnelly 
Assigned To 
PrioritynormalSeveritymajorReproducibilityalways
StatusclosedResolutionno change required 
PlatformMicrosoftOSWindowsOS Version7 64bit
Product VersionCMake 3.0.2 
Target VersionFixed in Version 
Summary0015200: Odd quoting issue when mixing single, double and escaped quotes to COMMAND
DescriptionUsing the following CMakeList.txt:

add_executable (blender blender.c)

set(TARGETDIR_VER "C:/Program Files (x86)/Blender/share/blender/2.72")

add_custom_command(
  TARGET blender POST_BUILD MAIN_DEPENDENCY blender
  COMMAND ${CMAKE_COMMAND} -E echo 'now run: \"make install\" to copy runtime files and scripts to ${TARGETDIR_VER}'
)

Using any old blender.c (hello world will do)
And either "MSYS Makefiles" or "MinGW Makefiles" generators (actually I suspect any Makefile generator at all), we get badly quoted strings in CMakeFiles/blender.dir/build.make:

/C/cmake-3.0.2-win32-x86/bin/cmake.exe -E echo 'now run: "make install" to copy runtime files and scripts to "C:/Program Files (x86)/Blender/share/blender/2.72'"

It seems that the final ' and " have been swapped, which causes:
/bin/sh: -c: line 0: unexpected EOF while looking for matching `"'
Steps To Reproduceunzip quote-problem.7z, and from the MSYS2 shell enter:

/c/cmake-3.0.2-win32-x86/bin/cmake.exe -G'MSYS Makefiles'
make

and observe the error message above.
Additional InformationThis happens on the officially release 3.0.2 Windows binary and also on MSYS2's cmake.
TagsNo tags attached.
Attached Files7z file icon quote-problem.7z [^] (489 bytes) 2014-10-09 08:24

 Relationships

  Notes
(0037011)
Ray Donnelly (reporter)
2014-10-09 08:36

Testing on Linux, we get:

now run: "make install" to copy runtime files and scripts to C:/Program\ Files\ (x86)/Blender/share/blender/2.72
(0037013)
Brad King (manager)
2014-10-09 08:40

Try using the VERBATIM option to add_custom_command. It causes CMake to add proper escapes to send each argument through the build system shell correctly.
(0037014)
Ray Donnelly (reporter)
2014-10-09 08:40

FWIW, I don't think 'MSYS Makefiles' should apply the Windows-y quoting logic, and should instead behave like Linux, but for 'MinGW Makefiles' the quoting does of course need to be applied, just not incorrectly.
(0037015)
Ray Donnelly (reporter)
2014-10-09 08:44

VERBATIM does work around this bug, but is there any reason not to fix it?
(0037016)
Brad King (manager)
2014-10-09 08:44

Try something like this:

add_custom_command(
  TARGET blender POST_BUILD MAIN_DEPENDENCY blender
  VERBATIM COMMAND ${CMAKE_COMMAND} -E echo "now run: \"make install\" to copy runtime files and scripts to ${TARGETDIR_VER}"
  )
(0037017)
Brad King (manager)
2014-10-09 08:47

Re 0015200:0037015: The documentation of add_custom_command recommends VERBATIM because it enables correct behavior. However, LOTS of project code was written with hacks to work around the pre-VERBATIM behavior and "fixing" it would break that code by escaping the hacks. We do have the policy mechanism that could be used to fix it in a compatible way but feel that it would still be too disruptive now.
(0037018)
Ray Donnelly (reporter)
2014-10-09 08:56

Ok, thanks Brad, that's fine then.

Could the policy mechanism allow the fix to happen around CMake 4 time? (whenever that is), if so, can I request this?
(0038421)
Robert Maynard (manager)
2015-04-06 09:07

Closing resolved issues that have not been updated in more than 4 months.

 Issue History
Date Modified Username Field Change
2014-10-09 08:24 Ray Donnelly New Issue
2014-10-09 08:24 Ray Donnelly File Added: quote-problem.7z
2014-10-09 08:36 Ray Donnelly Note Added: 0037011
2014-10-09 08:40 Brad King Note Added: 0037013
2014-10-09 08:40 Ray Donnelly Note Added: 0037014
2014-10-09 08:44 Ray Donnelly Note Added: 0037015
2014-10-09 08:44 Brad King Note Added: 0037016
2014-10-09 08:47 Brad King Note Added: 0037017
2014-10-09 08:56 Ray Donnelly Note Added: 0037018
2014-10-09 09:05 Brad King Status new => resolved
2014-10-09 09:05 Brad King Resolution open => no change required
2015-04-06 09:07 Robert Maynard Note Added: 0038421
2015-04-06 09:07 Robert Maynard Status resolved => closed


Copyright © 2000 - 2018 MantisBT Team