Compile 9.0 without opengl

Is it possible to compile vtk 9.0 without opengl? The only thing we need is the IO module of legacy vtk files and binary xml vtk files (pvtp, vtp, pvtu, vtu, etc).

I found instructions about this from an email back in 2015: https://vtk.org/pipermail/vtkusers/2015-May/090922.html
Unfortunately, this doesn’t work anymore. CMake still complains that OpenGL is not found. Here is the output of CMake:
– Could NOT find OpenGL (missing: OPENGL_opengl_LIBRARY OPENGL_glx_LIBRARY OPENGL_INCLUDE_DIR OpenGL)
CMake Error at CMake/vtkModule.cmake:4145 (message):
Could not find the OpenGL external dependency.
Call Stack (most recent call first):
CMake/vtkModule.cmake:4695 (vtk_module_find_package)
Utilities/OpenGL/CMakeLists.txt:58 (vtk_module_third_party_external)

How should I configure CMake of vtk-9?

Thank you

1 Like

Finally figured it out by trial-and-error. The old cmake macros in the 2015 email have been changed. Here is a cmake script that works for me:

cmake \

-D CMAKE_INSTALL_PREFIX:FILEPATH="$SFTPATH"
-D CMAKE_BUILD_TYPE:STRING=“Release”
-D BUILD_SHARED_LIBS=OFF
-D CMAKE_CXX_COMPILER:STRING=“mpicxx”
-D CMAKE_C_COMPILER:STRING=“mpicc”
-D CMAKE_CXX_FLAGS:STRING="$CXXFLAGS"
-D CMAKE_C_FLAGS:STRING="$CFLAGS"
-D OpenMP_CXX_FLAGS:STRING="$OPENMP_CXX_FLAGS"
-D OpenMP_C_FLAGS:STRING="$OPENMP_C_FLAGS"
-D BUILD_TESTING=OFF
-D VTK_PYTHON_VERSION=3
-D VTK_SMP_IMPLEMENTATION_TYPE=“OpenMP”
-D VTK_WRAP_PYTHON:BOOL=OFF
-D VTK_GROUP_ENABLE_Imaging=NO
-D VTK_GROUP_ENABLE_MPI=NO
-D VTK_GROUP_ENABLE_Qt=NO
-D VTK_GROUP_ENABLE_StandAlone=NO
-D VTK_GROUP_ENABLE_Views=NO
-D VTK_GROUP_ENABLE_Web=NO
-D VTK_MODULE_ENABLE_VTK_CommonCore=YES
-D VTK_MODULE_ENABLE_VTK_CommonExecutionModel=YES
-D VTK_MODULE_ENABLE_VTK_CommonMath=YES
-D VTK_MODULE_ENABLE_VTK_CommonMisc=YES
-D VTK_MODULE_ENABLE_VTK_CommonSystem=YES
-D VTK_MODULE_ENABLE_VTK_CommonTransforms=YES
-D VTK_MODULE_ENABLE_VTK_IOCore=YES
-D VTK_MODULE_ENABLE_VTK_IOLegacy=YES
-D VTK_MODULE_ENABLE_VTK_IOParallelXML=YES
-D VTK_MODULE_ENABLE_VTK_IOXML=YES
-D VTK_MODULE_ENABLE_VTK_IOXMLParser=YES
-D VTK_MODULE_ENABLE_VTK_ParallelCore=YES
$EXTRA_ARGS
$VTK_PATH

1 Like

This worked for me with VTK version 9.0.3.

cmake -DBUILD_SHARED_LIBS:BOOL=OFF -DCMAKE_BUILD_TYPE:STRING=RELEASE -DBUILD_EXAMPLES=OFF -DBUILD_TESTING=OFF -DVTK_USE_SYSTEM_EXPAT:BOOL=ON -DVTK_USE_SYSTEM_ZLIB:BOOL=ON -DVTK_LEGACY_REMOVE=ON -DVTK_Group_Rendering=OFF -DVTK_Group_StandAlone=OFF -DVTK_RENDERING_BACKEND=None -DVTK_WRAP_PYTHON=OFF -DModule_vtkCommonCore=ON -DModule_vtkCommonDataModel=ON -DModule_vtkFiltersCore=ON -DModule_vtkImagingStencil=ON -DModule_vtkIOXML=ON -DModule_vtkIOImage=ON -DModule_vtkImagingSources=ON -DVTK_GROUP_ENABLE_Views=NO -DVTK_GROUP_ENABLE_Web=NO -DVTK_GROUP_ENABLE_Imaging=NO -DVTK_GROUP_ENABLE_Qt=DONT_WANT -DVTK_GROUP_ENABLE_Rendering=DONT_WANT -GNinja …/