Reputation: 1095
For a current project I only need a subset of VTK modules. Since there is no binary installer for Windows using VTK C++ (it seems installer for Python bindings are the only ones available) I need to build VTK from source. Furthermore as I’m using CI (appveyor and travis) I need to build VTK everytime I’m pushing to my repo, therefore I’d like to keep the build times to a minimum.
These are the headers I’m using in my project:
<QVTKWidget.h>
<vtkActor.h>
<vtkDataArray.h>
<vtkFloatArray.h>
<vtkMarchingCubes.h>
<vtkPointData.h>
<vtkPolyData.h>
<vtkPolyDataMapper.h>
<vtkPolyDataNormals.h>
<vtkRenderWindow.h>
<vtkRenderer.h>
<vtkSmartPointer.h>
<vtkStructuredPoints.h>
<vtkType.h>
<vtkUnsignedCharArray.h>
<vtkVersion.h>
I already tried to determine all needed modules with the script: Utilities/Maintenance/WhatModulesVTK.py, but still get some linker errors when compiling my project. It seems that QVTKWidget doesn’t get included correctly, but I might be wrong here. WhatModulesVTK gives me:
All modules referenced in the files:
find_package(VTK COMPONENTS
vtkCommonCore
vtkCommonDataModel
vtkFiltersCore
vtkRenderingCore
vtkRenderingOpenGL
)
which is already not quite right, as I use VTK 7.0.0 and there is no vtkRenderingOpenGL, but only vtkRenderingOpenGL2. My CMakeLists.txt for my project currenty looks like:
…
find_package(OpenCV REQUIRED core imgproc calib3d highgui)
find_package(Boost COMPONENTS filesystem system REQUIRED)
find_package(VTK 7.0 COMPONENTS vtkCommonCore vtkCommonDataModel vtkFiltersCore
vtkRenderingCore vtkRenderingOpenGL2 REQUIRED)
find_package(Qt5Widgets REQUIRED QUIET)
…
Using VTK as a dependency, I’m building it beforehand like this:
$ git clone https://github.com/Kitware/VTK
$ cd VTK && git checkout tags/v7.0.0
$ mkdir build && cd build
$ cmake -DVTK_QT_VERSION:STRING=5
-DQT_QMAKE_EXECUTABLE:PATH=c:/Qt/5.6/msvc2015_64/bin/qmake.exe
-DVTK_Group_Qt:BOOL=ON
# Here should be all needed modules, e.g. -DModule_vtkXXXXX:BOOL=ON
-DBUILD_SHARED_LIBS:BOOL=ON ..
$ cmake --build .
Is this approach correct in general? What module am I missing in order.
Any help is appreciated.
Upvotes: 1
Views: 1602
Reputation: 5229
If you want to minimize build times first disable the default groups:
-DVTK_Group_StandAlone=OFF -DVTK_Group_Rendering=OFF
Then switch on all the required modules.
QVTKWidget
is part of the module vtkGUISupportQt
so you should build just that (-DModule_vtkGUISupportQt=ON
instead of VTK_Group_Qt
).
For CI consider precompiling VTK on a similar machine (e.g. Ubuntu 14.04 for Travis), then upload the resulting zip of the package to a web host. Then you can download, unzip and cache the prebuilt package in the CI job. See this Travis setup for an example.
Another option would be to use the Conan package manager for which I created VTK packages recently.
Upvotes: 2