# Building vtk-9.2.2 with vtkDicom requires running cmake twice

**URL:** https://discourse.vtk.org/t/building-vtk-9-2-2-with-vtkdicom-requires-running-cmake-twice/9659
**Category:** Support
**Created:** [October 24, 2022, 7:52am UTC](https://discourse.vtk.org/t/building-vtk-9-2-2-with-vtkdicom-requires-running-cmake-twice/9659 "2022-10-24T07:52:20Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![Carol\_Capek](https://discourse.vtk.org/user_avatar/discourse.vtk.org/carol_capek/32/3451_2.png) [@Carol\_Capek](https://discourse.vtk.org/u/Carol_Capek)
#### Post date: [October 24, 2022, 7:52am UTC](https://discourse.vtk.org/t/building-vtk-9-2-2-with-vtkdicom-requires-running-cmake-twice/9659/1 "2022-10-24T07:52:20Z")

</div>

Hello,

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

```auto
cmake ../ -GNinja -DCMAKE_INSTALL_PREFIX=/opt/VTK-9.2.2 -DBUILD_SHARED_LIBS=false
-DCMAKE_BUILD_TYPE=Release -DVTK_MODULE_ENABLE_VTK_DICOM=YES 
-DVTK_MODULE_ENABLE_VTK_RenderingExternal=YES -DVTK_MODULE_ENABLE_VTK_RenderingExternal=YES
-DVTK_MODULE_ENABLE_VTK_CommonCore=YES -DVTK_MODULE_ENABLE_VTK_CommonDataModel=YES
-DVTK_MODULE_ENABLE_VTK_FiltersCore=YES -DVTK_MODULE_ENABLE_VTK_FiltersSources=YES -DVTK_MODULE_ENABLE_VTK_IOImage=YES
-DVTK_MODULE_ENABLE_VTK_ImagingHybrid=YES -DVTK_MODULE_ENABLE_VTK_InteractionImage=YES
-DVTK_MODULE_ENABLE_VTK_InteractionStyle=YES -DVTK_MODULE_ENABLE_VTK_RenderingContextOpenGL2=YES
-DVTK_MODULE_ENABLE_VTK_RenderingCore=YES -DVTK_MODULE_ENABLE_VTK_RenderingFreeType=YES
-DVTK_MODULE_ENABLE_VTK_RenderingGL2PSOpenGL2=YES -DVTK_MODULE_ENABLE_VTK_RenderingOpenGL2=YES
-DVTK_MODULE_ENABLE_VTK_CommonColor=YES -DVTK_MODULE_ENABLE_VTK_vtkDICOM=YES 
-DUSE_DCMTK=true -DDCMTK_charls_LIBRARY=/usr/lib/x86_64-linux-gnu/libCharLS.so

```

(added new lines for readability)

I get the error:

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

    VTK_MODULE_ENABLE_VTK_vtkDICOM

```

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?

---

<div class="post-metadata">

### Author: ![Aron\_Helser](https://discourse.vtk.org/user_avatar/discourse.vtk.org/aron_helser/32/14_2.png) [@Aron\_Helser](https://discourse.vtk.org/u/Aron_Helser)
#### Post date: [October 24, 2022, 12:57pm UTC](https://discourse.vtk.org/t/building-vtk-9-2-2-with-vtkdicom-requires-running-cmake-twice/9659/2 "2022-10-24T12:57:18Z")

</div>

You have a duplicate with a typo:

`-DVTK_MODULE_ENABLE_VTK_DICOM=YES`

and

```auto
-DVTK_MODULE_ENABLE_VTK_vtkDICOM=YES

```

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.

HTH,  
Aron

---

<div class="post-metadata">

### Author: ![Carol\_Capek](https://discourse.vtk.org/user_avatar/discourse.vtk.org/carol_capek/32/3451_2.png) [@Carol\_Capek](https://discourse.vtk.org/u/Carol_Capek)
#### Post date: [October 24, 2022, 1:11pm UTC](https://discourse.vtk.org/t/building-vtk-9-2-2-with-vtkdicom-requires-running-cmake-twice/9659/3 "2022-10-24T13:11:48Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![dgobbi](https://discourse.vtk.org/user_avatar/discourse.vtk.org/dgobbi/32/18_2.png) [@dgobbi](https://discourse.vtk.org/u/dgobbi)
#### Post date: [October 24, 2022, 3:22pm UTC](https://discourse.vtk.org/t/building-vtk-9-2-2-with-vtkdicom-requires-running-cmake-twice/9659/4 "2022-10-24T15:22:59Z")

</div>

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

```nohighlight
vtk_fetch_module(vtkDICOM ...)

```

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

```nohighlight
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`.

---

<div class="post-metadata">

### Author: ![Carol\_Capek](https://discourse.vtk.org/user_avatar/discourse.vtk.org/carol_capek/32/3451_2.png) [@Carol\_Capek](https://discourse.vtk.org/u/Carol_Capek)
#### Post date: [October 24, 2022, 3:44pm UTC](https://discourse.vtk.org/t/building-vtk-9-2-2-with-vtkdicom-requires-running-cmake-twice/9659/5 "2022-10-24T15:44:41Z")

</div>

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?

---

<div class="post-metadata">

### Author: ![dgobbi](https://discourse.vtk.org/user_avatar/discourse.vtk.org/dgobbi/32/18_2.png) [@dgobbi](https://discourse.vtk.org/u/dgobbi)
#### Post date: [October 24, 2022, 6:05pm UTC](https://discourse.vtk.org/t/building-vtk-9-2-2-with-vtkdicom-requires-running-cmake-twice/9659/6 "2022-10-24T18:05:13Z")

</div>

> [@Carol\_Capek](#):
>
> So I’m wrong in my understanding that `VTK_MODULE_ENABLE_VTK_DICOM` enables the internal dicom module in vtk?

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?
