Search code examples
cmakevtk

Finding a given VTK module with CMake


I am currently trying to add a clipping plane to my dataset on vtk for android. No problem on the code so far but I have issues building the .apk as my program will not compile. In order to be able to use the clipping plane as I intend to I have the following includes:

#include <vtkTransformPolyDataFilter.h>
#include <vtkClipPolyData.h>
#include <vtkSampleFunction.h>
#include <vtkPlane.h>
#include <vtkImplicitPlaneWidget2.h>
#include <vtkImplicitPlaneRepresentation.h>

Yet when I try to compile (thanks to a Cmake generated Makefile) I get:

error: vtkImplicitPlaneWidget2.h: No such file or directory
 #include <vtkImplicitPlaneWidget2.h>

So I thought that I should try and add the vtkInteractionWidgets component to my find_package() in my CMakeLists.txt to obtain this:

find_package(VTK COMPONENTS
  vtkInteractionStyle
  vtkRenderingOpenGL2
  vtkRenderingVolumeOpenGL2
  vtkRenderingFreeType
)

Yet when I do so, I get:

Requested modules not available:
vtkInteractionWidgets

So I checked my modules list in my vtkbin/lib/cmake/vtk-7.1/Modules and I can clearly see: vtkInteractionWidgets.cmake

Any help would be appreciated, thanks in advance :).


EDIT:

I did check VTKConfig.cmake which has: set(VTK_MODULES_DIR "/Users/.../VTK/vtkbin/lib/cmake/vtk-7.1/Modules"). This directory as stated above does contain the vtkInteractionWidgets.cmake.

However I noticed that my /Users/.../VTK/vtkbin/CMakeExternals/Install/vtk-android/lib does not contain the equivalent lib. The only lib that I have containing the keyword interaction is: libvtkInteractionStyle-7.1.a


Solution

  • So it turns this has to be done manually in the vtkAndroid.cmake file in VTK_SOURCE/CMake/vtkAndroid.cmake. There should be inside some lines to manually add each needed modules:

    # Now cross-compile VTK with the android toolchain
    set(android_make_flags
      -DANDROID_NDK:PATH=${ANDROID_NDK}
      #...
      -DModule_vtkFiltersCore:BOOL=ON
      #...
    

    In my case I needed to add: -DModule_vtkInteractionWidgets:BOOL=ON