View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0013506CMakeCMakepublic2012-08-31 11:382015-06-01 08:38
ReporterJaime Frey 
Assigned To 
PrioritynormalSeverityminorReproducibilityalways
StatusclosedResolutionno change required 
PlatformAppleOSMac OS XOS Version10.8
Product VersionCMake 2.8.9 
Target VersionFixed in Version 
Summary0013506: CMAKE_COMMAND variable must always be quoted when using Mac application bundle
DescriptionWhen you install the Mac application bundle for CMake, the CMAKE_COMMAND variable ends up being "/Applications/CMake 2.8-9.app/Contents/bin/cmake". Note the presence of a space in the path. Any time you try to use the execute_process() function to run cmake using the ${CMAKE_COMMAND} variable, it will silent fail because it thinks you're trying to run the command "/Applications/CMake" with a first argument of "2.8-9.app/Contents/bin/cmake". To avoid this, you must enclose ${CMAKE_COMMAND} in quotes every time you use it.

All of the example usage I found of ${CMAKE_COMMAND} online does not quote it and would be bitten by this behavior.

We use execute_process() to run ${CMAKE_COMMAND} with the -E option in numerous places in our build files, and it would be easy for someone to forget to quote ${CMAKE_COMMAND}. The best solution we have for now is to manually rename the application bundle on our Macs to remove the space.

I believe this same problem applies to the variables CMAKE_CTEST_COMMAND and CMAKE_EDIT_COMMAND.
TagsNo tags attached.
Attached Files

 Relationships

  Notes
(0030811)
Brad King (manager)
2012-08-31 11:47

The CMake language splits unquoted arguments on ';', not spaces. I do

 execute_process(COMMAND ${CMAKE_COMMAND} ...)

all the time with spaces in the path. There must be something more specific about your case.
(0030812)
David Cole (manager)
2012-08-31 11:56

What are your exact steps to reproduce the problem?

Using execute_process or add_custom_command with:

  COMMAND ${CMAKE_COMMAND} ...

works without any double quotes.

Let us know how to reproduce the problem you're seeing...
(0033493)
Chris Vermilion (reporter)
2013-07-07 21:00

Found this issue Googling a similar problem. I'm not sure if this is the original submitter's situation, but I came across the issue in a custom-generated installation script for an external package built with ExternalProject. Our main CMake process generates a install-some-package.cmake file which is later included. The code to write the install script includes a line like this:

execute_process (COMMAND ${CMAKE_COMMAND} -E create_symlink ... )

That works fine called directly, but if you first write it to a file and then read it again it breaks, since the space in the expanded variable is treated differently.

I'm not sure if this is really a bug, since it seems like the right thing to do here is escape the command so that the script gets written with "${CMAKE_COMMAND}" rather in its expanded value, but I thought this might shed a little light on the issue.
(0033499)
Brad King (manager)
2013-07-08 08:35

Re 0013506:0033493: Yes, if you're generating a .cmake file to be later loaded it is your responsibility to make sure it is correct syntax. CMake syntax separates arguments by whitespace so if you have an argument with spaces it needs to be quoted. Of course you could also make sure that ${CMAKE_COMMAND} appears literally by using "\$" to avoid expansion of the variable reference in the code that is writing the script.
(0033500)
Brad King (manager)
2013-07-08 08:36

@Jaime Frey: Is the unquoted case that you encountered in code generated by CMake or in a file generated by your own project?
(0037825)
Jaime Frey (reporter)
2015-01-26 18:21

Sorry for the very late reply. At the time, we worked around the problem by renaming the installation path to remove the space. We've re-encountered it this week on a fresh build machine.

The code in question was written by us, following an example we found somewhere inline:

  install ( CODE "EXECUTE_PROCESS(COMMAND ${CMAKE_COMMAND} -E create_symlink source destination)" )

It appears the quoting around execute_process() was causing ${CMAKE_COMMAND} to be broken up into two arguments at the space. The solution I found today is to add some escaped quotes:

  install ( CODE "EXECUTE_PROCESS(COMMAND \"${CMAKE_COMMAND}\" -E create_symlink source destination)" )
(0037829)
Brad King (manager)
2015-01-27 08:32

Re 0013506:0037825: Okay, that one valid solution. Another is to escape the dollar sign so that ${CMAKE_COMMAND} is written literally into the install script code for evaluation during install:

  install ( CODE "EXECUTE_PROCESS(COMMAND \${CMAKE_COMMAND} -E create_symlink source destination)" )
(0038860)
Robert Maynard (manager)
2015-06-01 08:38

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

 Issue History
Date Modified Username Field Change
2012-08-31 11:38 Jaime Frey New Issue
2012-08-31 11:47 Brad King Note Added: 0030811
2012-08-31 11:56 David Cole Note Added: 0030812
2013-07-07 21:00 Chris Vermilion Note Added: 0033493
2013-07-08 08:35 Brad King Note Added: 0033499
2013-07-08 08:36 Brad King Note Added: 0033500
2013-07-08 08:36 Brad King Status new => backlog
2015-01-26 18:21 Jaime Frey Note Added: 0037825
2015-01-27 08:32 Brad King Note Added: 0037829
2015-01-27 08:32 Brad King Status backlog => resolved
2015-01-27 08:32 Brad King Resolution open => no change required
2015-06-01 08:38 Robert Maynard Note Added: 0038860
2015-06-01 08:38 Robert Maynard Status resolved => closed


Copyright © 2000 - 2018 MantisBT Team