| View Issue Details [ Jump to Notes ] | [ Print ] | ||||||||
| ID | Project | Category | View Status | Date Submitted | Last Update | ||||
| 0003786 | CMake | CMake | public | 2006-09-20 23:53 | 2006-10-04 20:09 | ||||
| Reporter | Brandon Van Every | ||||||||
| Assigned To | Brad King | ||||||||
| Priority | normal | Severity | major | Reproducibility | always | ||||
| Status | closed | Resolution | fixed | ||||||
| Platform | OS | OS Version | |||||||
| Product Version | |||||||||
| Target Version | Fixed in Version | ||||||||
| Summary | 0003786: COMMAND consumes twice as many escapes as expected | ||||||||
| Description | When using the MSVC and MSYS generators, proper Windows native paths (with quotes, whitespace, and backslashes for directories) are frequently needed in a custom COMMAND. Such a COMMAND consumes twice as many backslashes as an IF(...) construct. This makes it impossible to pass native Windows paths around as strings. Reproducer: 1. write a CMakeLists.txt: IF(EXISTS "E:\\Program Files\\Internet Explorer\\iexplore.exe") MESSAGE("IE exists.") ELSE(EXISTS "E:\\Program Files\\Internet Explorer\\iexplore.exe") MESSAGE("IE does not exist.") ENDIF(EXISTS "E:\\Program Files\\Internet Explorer\\iexplore.exe") ADD_CUSTOM_TARGET(backslash2 COMMAND "E:\\Program Files\\Internet Explorer\\iexplore.exe" & ) ADD_CUSTOM_TARGET(backslash4 COMMAND "E:\\\\Program Files\\\\Internet Explorer\\\\iexplore.exe" & ) 2. generate for MSYS with CMakeSetup. On almost any Windows system, the presence of Internet Explorer will be confirmed. 3. $ make backslash2 /bin/sh: E:Program FilesInternet Exploreriexplore.exe: command not found Built target backslash2 4. $ make backslash4 Built target backslash4 Internet Explorer will open. | ||||||||
| Tags | No tags attached. | ||||||||
| Attached Files | |||||||||
| Relationships | |
| Relationships |
| Notes | |
|
(0004987) Brandon Van Every (reporter) 2006-09-21 04:07 |
The failure is specific to MSYS. Using the "Visual Studio .NET 2003" generator, both backslash2 and backslash4 will open Internet Explorer. Looking at their Properties, they both reduce to "E:\Program Files\Internet Explorer\iexplore.exe". It appears that MSVC elides arbitrary numbers of escapes. This may prove problematic. MinGW and MSVC applications typically need the same native Windows paths, and they should behave in the same way in CMake. |
|
(0004988) Brandon Van Every (reporter) 2006-09-21 04:13 |
That's bizarre, the bug tracker nuked my backslashes. The above should have read: Looking at their Properties, they both reduce to "E:\Program Files\Internet Explorer\iexplore.exe". |
|
(0004989) Brandon Van Every (reporter) 2006-09-21 04:15 |
!#@$!$!@$#!@ So do parentheses make the difference??!? (Looking at their Properties, they both reduce to "E:\Program Files\Internet Explorer\iexplore.exe".) |
|
(0004990) Brandon Van Every (reporter) 2006-09-21 04:20 |
Aha. The bug tracker *IS* consistently killing backslashes. There's supposed to be *2* backslashes in every line of my reproducer. It should read: 1. write a CMakeLists.txt: IF(EXISTS "E:\\\\Program Files\\\\Internet Explorer\\\\iexplore.exe") MESSAGE("IE exists.") ELSE(EXISTS "E:\\\\Program Files\\\\Internet Explorer\\\\iexplore.exe") MESSAGE("IE does not exist.") ENDIF(EXISTS "E:\\\\Program Files\\\\Internet Explorer\\\\iexplore.exe") ADD_CUSTOM_TARGET(backslash2 COMMAND "E:\\\\Program Files\\\\Internet Explorer\\\\iexplore.exe" & ) ADD_CUSTOM_TARGET(backslash4 COMMAND "E:\\\\\\\\Program Files\\\\\\\\Internet Explorer\\\\\\\\iexplore.exe" & ) I will file a bug about the @!#$#!@#$ bug tracker. |
|
(0004992) Bill Hoffman (manager) 2006-09-21 09:00 |
Inside CMakeLists.txt files only unix sytle paths can be used. CMake should convert to a windows path before running the command. |
|
(0004994) Brad King (manager) 2006-09-21 10:34 |
This forward-slash rule is correct for the *executable* at the beginning of the command line. For the remaining arguments the behavior is currently inconsistent. Since we do not know whether they are paths or not we cannot convert them properly. Instead we should just preserve the exact string received by the ADD_CUSTOM_TARGET or ADD_CUSTOM_COMMAND command. This is not done consistently across the generators. |
|
(0004996) Brandon Van Every (reporter) 2006-09-21 11:46 |
In the docs, the syntax given for ADD_CUSTOM_COMMAND and ADD_CUSTOM_TARGET IS: COMMAND command1 [ARGS] [args1...] If command1 is required to be a CMake path, this should be documented. This is not quite a "custom" command but a hybrid between what CMake needs and what the user would expect. |
|
(0004997) Brandon Van Every (reporter) 2006-09-21 13:21 |
Additionally, if the CMake path for command1 contains whitespace, it must be quoted, i.e. COMMAND "${MY_WINDOWS_EXE}" <whatever args> Otherwise the command will fail on thing such as E:\Program Files\MyApp\whatever.exe. This should be documented in ADD_CUSTOM_COMMAND and ADD_CUSTOM_TARGET. It is not a bug, but it is a common pitfall. |
|
(0004999) Brad King (manager) 2006-09-21 14:44 |
Bug 0003788 complains that "!" (exclamation point) is not properly escaped. |
|
(0005000) Brad King (manager) 2006-09-21 14:44 |
I'm assigning this bug to myself because I'm fixing it. |
|
(0005001) Brad King (manager) 2006-09-21 15:14 |
The following changes address this problem on all Windows/Cygwin platforms: /cvsroot/CMake/CMake/Source/cmGlobalVisualStudio8Generator.cxx,v <-- cmGlobalVisualStudio8Generator.cxx new revision: 1.13; previous revision: 1.12 /cvsroot/CMake/CMake/Source/cmLocalGenerator.cxx,v <-- cmLocalGenerator.cxx new revision: 1.148; previous revision: 1.147 /cvsroot/CMake/CMake/Source/cmLocalGenerator.h,v <-- cmLocalGenerator.h new revision: 1.63; previous revision: 1.62 /cvsroot/CMake/CMake/Source/cmLocalUnixMakefileGenerator3.cxx,v <-- cmLocalUnixMakefileGenerator3.cxx new revision: 1.174; previous revision: 1.173 /cvsroot/CMake/CMake/Source/cmLocalVisualStudio6Generator.cxx,v <-- cmLocalVisualStudio6Generator.cxx new revision: 1.104; previous revision: 1.103 /cvsroot/CMake/CMake/Source/cmLocalVisualStudio7Generator.cxx,v <-- cmLocalVisualStudio7Generator.cxx new revision: 1.146; previous revision: 1.145 /cvsroot/CMake/CMake/Source/cmLocalVisualStudioGenerator.cxx,v <-- cmLocalVisualStudioGenerator.cxx new revision: 1.6; previous revision: 1.5 /cvsroot/CMake/CMake/Source/cmLocalVisualStudioGenerator.h,v <-- cmLocalVisualStudioGenerator.h new revision: 1.3; previous revision: 1.2 |
|
(0005002) Brad King (manager) 2006-09-21 15:30 |
Parentheses cannot be escaped because $(FOO) make variable syntax must work: /cvsroot/CMake/CMake/Source/cmLocalGenerator.cxx,v <-- cmLocalGenerator.cxx new revision: 1.149; previous revision: 1.148 |
|
(0005003) Brad King (manager) 2006-09-21 15:36 |
Need to escape spaces in posix shells. /cvsroot/CMake/CMake/Source/cmLocalGenerator.cxx,v <-- cmLocalGenerator.cxx new revision: 1.150; previous revision: 1.149 |
|
(0005004) Brandon Van Every (reporter) 2006-09-21 15:39 |
Parentheses cannot be escaped, even in a quoted string? That is severely limiting to Lisp and Scheme programmers. |
|
(0005005) Brad King (manager) 2006-09-21 15:55 |
The $(FOO) syntax works in all generators' native build tools to reference build-time variables (like "$(OutDir)" in VS). This has to continue to work. |
|
(0005006) Brandon Van Every (reporter) 2006-09-21 16:00 |
But $( is what you're looking for in that case, right? It may be difficult to escape parentheses given your current implementation, but there's nothing stopping it in principle, right? If so, I will file a feature request. In any event, these various limitations of what the COMMAND requires, and can and cannot do, need to be documented. |
|
(0005007) Brad King (manager) 2006-09-21 16:09 |
Please don't create a feature request separately for just $(). That commit was an emergency dashboard fix. I do intend to investigate it further before closing this bug. |
|
(0005008) Brad King (manager) 2006-09-21 16:11 |
These changes enable the fix for Xcode: /cvsroot/CMake/CMake/Source/cmGlobalXCodeGenerator.cxx,v <-- cmGlobalXCodeGenerator.cxx new revision: 1.121; previous revision: 1.120 /cvsroot/CMake/CMake/Source/cmLocalGenerator.h,v <-- cmLocalGenerator.h new revision: 1.64; previous revision: 1.63 |
|
(0005009) Brad King (manager) 2006-09-21 16:11 |
These changes add a test: /cvsroot/CMake/CMake/Tests/CustomCommand/CMakeLists.txt,v <-- CMakeLists.txt new revision: 1.15; previous revision: 1.14 /cvsroot/CMake/CMake/Tests/CustomCommand/check_command_line.c.in,v <-- check_command_line.c.in initial revision: 1.1 |
|
(0005014) Brandon Van Every (reporter) 2006-09-23 01:05 |
Thanks for your activity on this, Brad. Let me know when your design has reached a point of stability, and you want me to test the results in CMake CVS. |
|
(0005017) Brad King (manager) 2006-09-23 16:38 |
One user reported that the code below is broken by the fix for this bug. The problem is that fixing the bug breaks code that worked around its existence in the first place. I'll have to do something more for backward compatibility. Perhaps a different signature for doing the proper quoting, or testing CMAKE_BACKWARDS_COMPATIBILITY. > # CMakeLists.txt > add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/foo > COMMAND > ${CMAKE_COMMAND} > -DTOPS:FILEPATH=${CMAKE_SOURCE_DIR} -DTOPS:FILEPATH="${CMAKE_SOURCE_DIR}" > -DTOPB:FILEPATH=${CMAKE_BINARY_DIR} > -P ${CMAKE_SOURCE_DIR}/script.cmake > ) > add_custom_target(drive ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/foo) > i.e., the argument is quoted. i thought i verified it makes no difference, but i think i became victim of the cache or some dep problems. |
|
(0005022) Brad King (manager) 2006-09-23 17:00 |
Bug 0003664 is related to this. |
|
(0005027) Brad King (manager) 2006-09-25 10:23 |
The following changes disable this fix until backwards compatiblity can be established: /cvsroot/CMake/CMake/Source/cmLocalGenerator.cxx,v <-- cmLocalGenerator.cxx new revision: 1.151; previous revision: 1.150 /cvsroot/CMake/CMake/Tests/CustomCommand/CMakeLists.txt,v <-- CMakeLists.txt new revision: 1.17; previous revision: 1.16 |
|
(0005053) Brad King (manager) 2006-09-27 13:45 |
The following changes implement more robust escaping. They also setup an internal implementation framework to allow this support to be enabled through ADD_CUSTOM_COMMAND and ADD_CUSTOM_TARGET in a backwards-compatible way. /cvsroot/CMake/CMake/Source/cmCustomCommand.cxx,v <-- cmCustomCommand.cxx new revision: 1.18; previous revision: 1.17 /cvsroot/CMake/CMake/Source/cmCustomCommand.h,v <-- cmCustomCommand.h new revision: 1.18; previous revision: 1.17 /cvsroot/CMake/CMake/Source/cmGlobalXCodeGenerator.cxx,v <-- cmGlobalXCodeGenerator.cxx new revision: 1.122; previous revision: 1.121 /cvsroot/CMake/CMake/Source/cmLocalGenerator.cxx,v <-- cmLocalGenerator.cxx new revision: 1.152; previous revision: 1.151 /cvsroot/CMake/CMake/Source/cmLocalGenerator.h,v <-- cmLocalGenerator.h new revision: 1.65; previous revision: 1.64 /cvsroot/CMake/CMake/Source/cmLocalUnixMakefileGenerator3.cxx,v <-- cmLocalUnixMakefileGenerator3.cxx new revision: 1.176; previous revision: 1.175 /cvsroot/CMake/CMake/Source/cmLocalVisualStudio6Generator.cxx,v <-- cmLocalVisualStudio6Generator.cxx new revision: 1.105; previous revision: 1.104 /cvsroot/CMake/CMake/Source/cmLocalVisualStudio7Generator.cxx,v <-- cmLocalVisualStudio7Generator.cxx new revision: 1.147; previous revision: 1.146 /cvsroot/CMake/CMake/Source/cmLocalVisualStudioGenerator.cxx,v <-- cmLocalVisualStudioGenerator.cxx new revision: 1.7; previous revision: 1.6 /cvsroot/CMake/CMake/Source/cmLocalVisualStudioGenerator.h,v <-- cmLocalVisualStudioGenerator.h new revision: 1.4; previous revision: 1.3 /cvsroot/CMake/CMake/Source/kwsys/ProcessWin32.c,v <-- ProcessWin32.c new revision: 1.64; previous revision: 1.63 /cvsroot/CMake/CMake/Source/kwsys/System.c,v <-- System.c new revision: 1.3; previous revision: 1.2 /cvsroot/CMake/CMake/Source/kwsys/System.h.in,v <-- System.h.in new revision: 1.2; previous revision: 1.1 |
|
(0005055) Brad King (manager) 2006-09-27 15:26 |
Fix for custom command copy constructor: /cvsroot/CMake/CMake/Source/cmCustomCommand.cxx,v <-- cmCustomCommand.cxx new revision: 1.19; previous revision: 1.18 |
|
(0005062) Brad King (manager) 2006-09-28 11:32 |
The following changes enable this functionality and add a test. A new VERBATIM option must be given to ADD_CUSTOM_COMMAND or ADD_CUSTOM_TARGET to make its arguments get escaped with the new code. This is necessary for compatibility with older scripts. /cvsroot/CMake/CMake/Source/cmAddCustomCommandCommand.cxx,v <-- cmAddCustomCommandCommand.cxx new revision: 1.32; previous revision: 1.31 /cvsroot/CMake/CMake/Source/cmAddCustomCommandCommand.h,v <-- cmAddCustomCommandCommand.h new revision: 1.24; previous revision: 1.23 /cvsroot/CMake/CMake/Source/cmAddCustomTargetCommand.cxx,v <-- cmAddCustomTargetCommand.cxx new revision: 1.23; previous revision: 1.22 /cvsroot/CMake/CMake/Source/cmAddCustomTargetCommand.h,v <-- cmAddCustomTargetCommand.h new revision: 1.19; previous revision: 1.18 /cvsroot/CMake/CMake/Source/cmMakefile.cxx,v <-- cmMakefile.cxx new revision: 1.353; previous revision: 1.352 /cvsroot/CMake/CMake/Source/cmMakefile.h,v <-- cmMakefile.h new revision: 1.191; previous revision: 1.190 /cvsroot/CMake/CMake/Tests/CustomCommand/CMakeLists.txt,v <-- CMakeLists.txt new revision: 1.18; previous revision: 1.17 /cvsroot/CMake/CMake/Tests/CustomCommand/check_command_line.c.in,v <-- check_command_line.c.in new revision: 1.2; previous revision: 1.1 |
|
(0005075) Brad King (manager) 2006-10-02 10:25 |
Brandon, I'm closing this bug because I think it is now fixed. Please try using the VERBATIM option to see if it suits your needs. Re-open the bug if necessary. |
|
(0005203) Brad King (manager) 2006-10-04 18:53 |
The following changes enable use of this escaping implementation to display custom command COMMENTs properly. /cvsroot/CMake/CMake/Source/kwsys/System.c,v <-- System.c new revision: 1.4; previous revision: 1.3 /cvsroot/CMake/CMake/Source/kwsys/System.h.in,v <-- System.h.in new revision: 1.3; previous revision: 1.2 /cvsroot/CMake/CMake/Source/cmGlobalBorlandMakefileGenerator.cxx,v <-- cmGlobalBorlandMakefileGenerator.cxx new revision: 1.24; previous revision: 1.23 /cvsroot/CMake/CMake/Source/cmGlobalNMakeMakefileGenerator.cxx,v <-- cmGlobalNMakeMakefileGenerator.cxx new revision: 1.23; previous revision: 1.22 /cvsroot/CMake/CMake/Source/cmGlobalWatcomWMakeGenerator.cxx,v <-- cmGlobalWatcomWMakeGenerator.cxx new revision: 1.9; previous revision: 1.8 /cvsroot/CMake/CMake/Source/cmLocalGenerator.cxx,v <-- cmLocalGenerator.cxx new revision: 1.156; previous revision: 1.155 /cvsroot/CMake/CMake/Source/cmLocalGenerator.h,v <-- cmLocalGenerator.h new revision: 1.68; previous revision: 1.67 /cvsroot/CMake/CMake/Source/cmLocalUnixMakefileGenerator3.cxx,v <-- cmLocalUnixMakefileGenerator3.cxx new revision: 1.180; previous revision: 1.179 /cvsroot/CMake/CMake/Source/cmLocalUnixMakefileGenerator3.h,v <-- cmLocalUnixMakefileGenerator3.h new revision: 1.61; previous revision: 1.60 |
|
(0005204) Brad King (manager) 2006-10-04 18:58 |
Added a test for comment escaping. /cvsroot/CMake/CMake/Tests/CustomCommand/CMakeLists.txt,v <-- CMakeLists.txt new revision: 1.23; previous revision: 1.22 |
|
(0005221) Brad King (manager) 2006-10-04 20:09 |
Bug 0003570 should be fixed by this bug fix. |
| Notes |
| Issue History | |||
| Date Modified | Username | Field | Change |
| Issue History |
| Copyright © 2000 - 2018 MantisBT Team |