[vtkusers] VTK CVS: Build problems with Python

Gavin Baker gavinbSPAM at NOSPAMcs.mu.oz.au
Mon Jan 27 21:03:05 EST 2003


Hi,

I am building VTK from CVS (checked out morning of 28-Jan AEST) on
Debian woody, with gcc 2.95.4 and Python 2.2.1, and CMake 1.4p4.

I did a clean cvs checkout, ran 'cmake -i ../VTK' and straight away
get this error:

CMake Error: ADD_CUSTOM_COMMAND: Error :
ADD_CUSTOM_COMMAND Wrong syntax: Empty COMMAND. from CMakeLists.txt file in
directory /home/gavinb/projects/vtk/VTK/Wrapping/Python

    (repeated 12 times)

(It is most unfortunate that the error messages from CMake do not
include the line number of the error.)

I tracked down the problem to this entry in VTK/Wrapping/Python/CMakeLists.txt
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 problem is that PYTHON_EXECUTABLE isn't being set, and in the top
level CMakLists.txt, the FIND_PROGRAM for Python has some problems: it
is only getting set if BUILD_TESTING and DART_ROOT are both set, and
secondly, the PATHs are only provided for Windows (pulling them out of
the registry by the looks).

I think this could be fixed with something like this:

IF(VTK_WRAP_PYTHON)
  IF(WIN32)
    FIND_PROGRAM(PYTHON_EXECUTABLE
      NAMES python2.2 python2.1 python1.6 python1.5 python
      PATHS
       [HKEY_LOCAL_MACHINE...] # as in current version
    )
  END(WIN32)
  IF(UNIX)
    FIND_PROGRAM(PYTHON_EXECUTABLE
      NAMES python2.2 python2.1 python1.6 python1.5 python
      PATHS
        /usr/bin
        /usr/local/bin
        /opt/bin
    )
  END(UNIX)
END(VTK_WRAP_PYTHON)

The workaround is to invoke cmake like this:

% ccmake -i ../VTK -DPYTHON_EXECUTABLE:FILE=/usr/bin/python2.2

Note that if you put a space after the -D, CMake doesn't handle it too
gracefully, and gives a strange error that doesn't really reflect the
actual problem.

  :: Gavin

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



More information about the vtkusers mailing list