[vtkusers] Building the examples vtkLocal and vtkMy outside of VTK source tree (6.1.0)

Eric Nodwell eric.nodwell at gmail.com
Fri Jan 24 05:34:49 EST 2014


Hi,

We have a project of our local VTK classes that in VTK 5.x we built as
a separate package.  I'm trying to understand the optimal way to do
this in VTK 6 (using 6.1.0rc2). The build works except for the python
wrapping.  For simplicity, I've been experimenting with the two
example projects (in Examples/Build) vtkLocal and vtkMy.  It seems
like neither can be compiled unmodified if copied out of the VTK
source tree (they haven't been completely updated for VTK 6 yet??),
and for neither have I yet managed to get python wrapping working
(except with a pretty ugly kludge).

For the vtkLocal example, copied out of the VTK source tree, I had to
make one fix, replacing this line in CMakeLists:

find_package(VTK vtkCommonCore)

with this:

find_package(VTK COMPONENTS vtkCommonCore)

vtkLocal then compiles, but as a static library (although VTK itself
was complied as dynamic libraries), and without python wrapping (VTK
itself was compiled with python wrapping).  My impression is that the
vtkLocal method is intended to produce external modules in exactly the
same manner as VTK itself was compiled, with automatic wrapping
corresponding to the languages used for wrapping VTK itself, but
perhaps I am mistaken.

For vtkMy copied outside of the VTK tree, I was able to get it to
compile with some modifications.  For example, for
vtkMy/Common/CMakeLists.txt, I replaced these lines:

# Create the vtkmyCommon C++ library.
ADD_LIBRARY (vtkmyCommon ${Common_SRCS})
TARGET_LINK_LIBRARIES (vtkmyCommon vtkCommon)

with these:

find_package(VTK COMPONENTS
  vtkCommonCore
)
# Create the vtkmyCommon C++ library.
ADD_LIBRARY (vtkmyCommon ${Common_SRCS})
target_link_libraries(vtkmyCommon ${VTK_LIBRARIES})

And similarly for the other subdirectories.  Then it compiles fine,
but without Python wrapping.  I can't figure out an elegant way to get
Python wrapping to work.  A horrible ugly kludge is to crawl the list
of VTK libraries for linking and generate a corresponding list of
python libraries for linking.  That goes something like replacing this
line:

  TARGET_LINK_LIBRARIES(vtkmyCommonPythonD vtkmyCommon vtkCommon
vtkCommonPythonD)

with something like this (OS-X specific, but could always hack at it
more to handle more OSs):

    foreach (LIB ${VTK_LIBRARIES})
      set (FILE
"${VTK_DIR}/lib/lib${LIB}Python27D-${VTK_MAJOR_VERSION}.${VTK_MINOR_VERSION}.dylib")
      if (EXISTS ${FILE})
        set (MY_VTK_PYTHOND_LIBRARIES ${MY_VTK_PYTHOND_LIBRARIES} ${FILE})
      endif ()
    endforeach ()
    target_link_libraries(vtkmyPythonD
                          vtkmy
                          vtkmyPython
                          ${MY_VTK_PYTHOND_LIBRARIES}
                          ${VTK_PYTHON_LIBRARIES})

But this is obviously not what one is intended to do.

Any tips on getting vtkLocal and/ot vtkMy compiling with python
wrapping (and outside of the VTK source tree) would be much
appreciated.

Thanks,
Eric


More information about the vtkusers mailing list