Building vtk-9.2.2 with vtkDicom requires running cmake twice


I tried to build vtk-9.2.2 the other day and ran into a problem when running:

cmake ../ -GNinja -DCMAKE_INSTALL_PREFIX=/opt/VTK-9.2.2 -DBUILD_SHARED_LIBS=false
-DUSE_DCMTK=true -DDCMTK_charls_LIBRARY=/usr/lib/x86_64-linux-gnu/

(added new lines for readability)

I get the error:

CMake Warning:
  Manually-specified variables were not used by the project:


If I run cmake again the warning is gone and I can use vtkDicom as expected.

Since I am building vtk-9.2.2 automatized I actually don’t want to call cmake twice.
Can someone tell me what I am doing wrong? Is my cmake command wrong? Or is this the desired way of building vtk-9.2.2 with remote modules?

You have a duplicate with a typo:




Eliminate the second, and the warning will go away. Even with this warning, you did not need to run cmake twice to have a successful build.


Sorry, but that’s not correct. The two modules are two different things:

-DVTK_MODULE_ENABLE_VTK_DICOM=YES enables the VTK “build-in” DICOM module whereas

-DVTK_MODULE_ENABLE_VTK_vtkDICOM=YES enables the external module vtk-dicom.

The build goes through, but the module is not available, thus my project which uses the vtk-dicom headers doesn’t compile.

Btw. might be important: The cmake command worked with version 9.0.2 without problems.

The problem is caused because Remote/vtkDICOM.remote.cmake does this:

vtk_fetch_module(vtkDICOM ...)

when it should do this, since vtk.module for vtkDICOM refers to itself as VTK::DICOM:

vtk_fetch_module(DICOM ...)

It’s surprising this discrepancy has existed for so long (ever since vtkDICOM became a remote module, I believe).

So until this is fixed, you will have to continue to set both of those CMake variables and ignore the cmake warning. Or you can locally patch Remote/vtkDICOM.remote.cmake.

Thanks for your answer @dgobbi !

So I’m wrong in my understanding that VTK_MODULE_ENABLE_VTK_DICOM enables the internal dicom module in vtk? I guess I can cleanup this cmake command a little.

Do you have any explanation why this changed from v9.0.2 to v9.2.2? As I understand, vtkDICOM was already a remote module in 9.0.2, wasn’t it?

My understanding is that VTK_MODULE_ENABLE_VTK_vtkDICOM causes cmake to grab the vtkDICOM code via git, and that VTK_MODULE_ENABLE_VTK_DICOM enables the module. So I don’t think you’re wrong.

I don’t think this has changed at all between v9.0 and v9.2, so I can’t explain any differences you’re seeing (I can look into this, but not today unfortunately). Is there any chance that you are using a different version of CMake for your v9.2.2 build as compared to when you were building v9.0.2?