[vtkusers] CMake generating Makefiles: quoting problem

Gavin Baker gavinbSPAM at NOSPAMcs.mu.oz.au
Tue Jan 28 01:03:07 EST 2003


Hello,

I am building VTK from cvs (refreshed today), under Debian GNU/Linux
(woody), using CMake 1.4p4 (and my shell is bash 2.05b).

There are two problems with the Makefile generated by CMake,
specifically with the following section from
   VTK/Wrapping/Python/CMakeLists.txt starting on line 83:

  ADD_CUSTOM_COMMAND(SOURCE ${src}
    COMMAND ${PYTHON_EXECUTABLE}
    ARGS -c "\"import" "py_compile;py_compile.compile('${src}','${tgt}','${tgt}')\""
    TARGET vtkpython_pyc
    OUTPUTS ${tgt}
    )

The problems are:

1. CMake generates echo statements for each COMMAND/ARGS, with exactly
the same contents as the shell command to be executed.  But since the
above generated command includes quotes, the quotes are not escaped
for the echo line, even though that same line is correct for the
actual command.

The generated Makefile contains lines such as this:

/home/gavinb/projects/vtk/vtk-linux/Wrapping/Python/QVTKRenderWidget.pyc: /home/gavinb/projects/vtk/VTK/Wrapping/Python/QVTKRenderWidget.py
	echo "/usr/bin/python2.2 -c "import py_compile;py_compile.compile('/home/gavinb/projects/vtk/VTK/Wrapping/Python/QVTKRenderWidget.py','/home/gavinb/projects/vtk/vtk-linux/Wrapping/Python/QVTKRenderWidget.pyc','/home/gavinb/projects/vtk/vtk-linux/Wrapping/Python/QVTKRenderWidget.pyc')" "
	/usr/bin/python2.2 -c "import py_compile;py_compile.compile('/home/gavinb/projects/vtk/VTK/Wrapping/Python/QVTKRenderWidget.py','/home/gavinb/projects/vtk/vtk-linux/Wrapping/Python/QVTKRenderWidget.pyc','/home/gavinb/projects/vtk/vtk-linux/Wrapping/Python/QVTKRenderWidget.pyc')" 

When make is run, the following error occurs:

/bin/sh: -c: line 1: syntax error near unexpected token `'/home/gavinb/projects/vtk/VTK/Wrapping/Python/vtk/filtering.py','/home/gavinb/projects/vtk/vtk-linux/Wrapping/Python/vtk/filtering.pyc','/home/gavinb/projects/vtk/vtk-linux/Wrapping/Python/vtk/filtering.pyc''
/bin/sh: -c: line 1: `echo "/usr/bin/python2.2 -c "import py_compile;py_compile.compile('/home/gavinb/projects/vtk/VTK/Wrapping/Python/vtk/filtering.py','/home/gavinb/projects/vtk/vtk-linux/Wrapping/Python/vtk/filtering.pyc','/home/gavinb/projects/vtk/vtk-linux/Wrapping/Python/vtk/filtering.pyc')" "'

I couldn't seem to find a combination of quotes and escaping that
would result in a valid and correct command line and something that
echo would accept at the same time.

The quick fix is to comment out the echo statements.  A proper fix
would be to get CMake to escape quotes when passing the command line
to echo.


2. There is a semicolon separating the import statement with the
compile call.  This exists in CMakeLists.txt but is removed when the
Makefile is generated.  The solution is to escape the semicolon with a
backslash, and it works fine.

Related to point 2 above, the documentation for CMake does not explain
the quoting or escaping rules.  It would be useful to have a reference
for that somewhere.

  :: Gavin

-- 
Gavin Baker                                Computer Vision Lab (CVMIL)
http://www.cs.mu.oz.au/~gavinb                 University of Melbourne



More information about the vtkusers mailing list