Build fails : VTK9 expected

Slicer build failed today on Arch Linux against VTK8. This trivial patch fixed the build process. I can’t know if it’s the right fix.

diff --git a/Libs/MRML/Core/vtkMRMLModelStorageNode.cxx b/Libs/MRML/Core/vtkMRMLModelStorageNode.cxx index e7e29785c7..a6851467cf 100644
--- a/Libs/MRML/Core/vtkMRMLModelStorageNode.cxx
+++ b/Libs/MRML/Core/vtkMRMLModelStorageNode.cxx
@@ -507,13 +507,17 @@ int vtkMRMLModelStorageNode::WriteDataInternal(vtkMRMLNode *refNode)
     if (modelNode->GetMeshType() == vtkMRMLModelNode::PolyDataMeshType)
       {
       writer = vtkSmartPointer<vtkPolyDataWriter>::New();
+#if VTK_MAJOR_VERSION >= 9 || (VTK_MAJOR_VERSION >= 8 && VTK_MINOR_VERSION >= 90)      
       writer->SetFileVersion(42);
+#endif      
       writer->SetInputData(meshToWrite);
       }
     else
       {
       writer = vtkSmartPointer<vtkUnstructuredGridWriter>::New();
+#if VTK_MAJOR_VERSION >= 9 || (VTK_MAJOR_VERSION >= 8 && VTK_MINOR_VERSION >= 90)
       writer->SetFileVersion(42);
+#endif
       writer->SetInputData(meshToWrite);
       }
 
diff --git a/Modules/CLI/ModelMaker/ModelMaker.cxx b/Modules/CLI/ModelMaker/ModelMaker.cxx
index 6c3b6065b1..374fad5c6c 100644
--- a/Modules/CLI/ModelMaker/ModelMaker.cxx
+++ b/Modules/CLI/ModelMaker/ModelMaker.cxx
@@ -1177,7 +1177,9 @@ int main(int argc, char * argv[])
       if (SaveIntermediateModels)
         {
         writer = vtkSmartPointer<vtkPolyDataWriter>::New();
+#if VTK_MAJOR_VERSION >= 9 || (VTK_MAJOR_VERSION >= 8 && VTK_MINOR_VERSION >= 90)
         writer->SetFileVersion(42);
+#endif
         std::string            commentSaveCubes = "Writing intermediate model after marching cubes " + labelName;
         vtkPluginFilterWatcher watchWriter(writer,
                                            commentSaveCubes.c_str(),

Regards.

1 Like

OK, Slicer nightly now ships with VTK9; this might explain why the code doesn’t check VTK version anymore. But VMTK extension is not available for VTK9. Until VMTK extension builds with VTK9, I’ll have to build Slicer with VTK8, as long as next fixes are as trivial as above. One more reason why self built Slicer may be of interest.

To follow up, errors discussed here have been fixed by @lassoan in these commits: