# Slicer Build takes too much time to compile using make command

**URL:** https://discourse.slicer.org/t/slicer-build-takes-too-much-time-to-compile-using-make-command/15828
**Category:** Development
**Tags:** build
**Created:** [February 4, 2021, 7:03am UTC](https://discourse.slicer.org/t/slicer-build-takes-too-much-time-to-compile-using-make-command/15828 "2021-02-04T07:03:15Z")
**Posts on this page:** 12
**Page:** 1

<div class="post-metadata">

### Author: ![Hanumant\_Gawali](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/hanumant_gawali/32/9645_2.png) [@Hanumant\_Gawali](https://discourse.slicer.org/u/Hanumant_Gawali)
#### Post date: [February 4, 2021, 7:03am UTC](https://discourse.slicer.org/t/slicer-build-takes-too-much-time-to-compile-using-make-command/15828/1 "2021-02-04T07:03:15Z")

</div>

Hi there,  
I am trying to build slicer from source code on ubuntu 20.04, I have executes command cmake and then make in debuge directory. It is taking too much time to build near about 10 hours. Please help me for understanding exact issue in build

---

<div class="post-metadata">

### Author: ![jcfr](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/jcfr/32/17825_2.png) [@jcfr](https://discourse.slicer.org/u/jcfr)
#### Post date: [February 4, 2021, 7:34am UTC](https://discourse.slicer.org/t/slicer-build-takes-too-much-time-to-compile-using-make-command/15828/2 "2021-02-04T07:34:18Z")

</div>

It should take between 1 and 3 hours.

To help identify the problem, here are few questions:

- What are the specs of your workstation ? number of cores, type of hard drive
- Are you running Ubuntu from within a virtual machine ?
- Are you building in parallel by specifying `make -jN` where `N` corresponds to the number of cores ?
- Do you have an antivirus running ?
- Are you building on a mounted network drive ?

---

<div class="post-metadata">

### Author: ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)
#### Post date: [February 4, 2021, 2:32pm UTC](https://discourse.slicer.org/t/slicer-build-takes-too-much-time-to-compile-using-make-command/15828/3 "2021-02-04T14:32:07Z")

</div>

On Windows, on a desktop computer a complete build takes 3-4 hours with default settings and 2 hours with parallel build enabled (CMake config:  
`ADDITIONAL_CXX_FLAGS=/MP`, `ADDITIONAL_C_FLAGS=/MP`; build with `cmake.exe --build . -j 8`). On an an ultrabook laptop, build typically takes 8-10 hours.

In practice, build time does not make a big difference, because it is too long anyway to wait for it to end while doing nothing else, so we just start it and it runs in the background while we are working on other things. Building after making changes is fast, takes 10-20 seconds if you build the entire inner Slicer-build folder and a few seconds if you build a subproject or on an extension.

---

<div class="post-metadata">

### Author: ![robertsoakes](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/robertsoakes/32/11042_2.png) [@robertsoakes](https://discourse.slicer.org/u/robertsoakes)
#### Post date: [May 24, 2021, 3:36pm UTC](https://discourse.slicer.org/t/slicer-build-takes-too-much-time-to-compile-using-make-command/15828/4 "2021-05-24T15:36:00Z")

</div>

@lassoan Can you provide any detail on how the incremental build system on Windows works? I’m trying to patch an issue preventing us from sending DICOM-SEG files back to our PACS system, and I haven’t been able to launch an incremental build.

If I invoke the build script from from the documentation in the root folder, I get a full end to end build (takes about four hours on my machine). I’ve been doing this by launching a the build command referenced in the documentation from the root of the build folder:

```bash
cmake.exe --build . --config Debug

```

Running the same command from the `Slicer-build` skips compilation of dependencies but still requires a significant amount of time to complete. (I started a compile of the folder, but stopped it after about 20 minutes.)

The last approach I’ve been taking is to compile in Visual Studio, but this also launches a full build rather than an incremental build and seems to require scores of minutes as well. Any suggestions would be appreciated.

PS, I’m pretty new to Slicer. Thank you for creating such a wonderful application. I’m coming from the Mimics world and it’s incredibly inspiring to see such a powerful piece of software available as open source.

---

<div class="post-metadata">

### Author: ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)
#### Post date: [May 25, 2021, 4:09am UTC](https://discourse.slicer.org/t/slicer-build-takes-too-much-time-to-compile-using-make-command/15828/5 "2021-05-25T04:09:08Z")

</div>

I usually open the `c:\D\S4D\Slicer-build\Slicer.sln` in Visual Studio (by going to `c:\S4D\Slicer-build` folder and launching `.\Slicer.exe --VisualStudioProject`) and run the `SlicerApp` project. I think some people also load .sln files in subfolders, which might further decrease build time

After a complete, successful build of SlicerApp, repeated build will only rebuild about 70 projects, typically in about a few minutes. About 10 of these are various quick tasks (copying Python files, etc), and the rest are updates of hierarchy files for the Python wrapper.

Based on your problem report, I did some investigation and found that update of hierarchy files is time consuming because vtkWrapHierarchy.exe searches for hundreds of header files in hundreds of include directories. Time to complete these hierarchy files updates depends on how quickly your computer can check for existence of a file. This is a very costly operation and may depend on the file system, antivirus software settings, storage hardware, operating system version, etc. As an experiment, I’ve implemented proof-of-concept pre-fetching and caching of all file paths in include directories in vtkWrapHierarchy, which made update of hierarchy files about 4-5x faster in debug mode. On my computer, a repeated build of SlicerApp project now takes about 50 seconds. I’ll discuss with VTK core developers if this improvement could be integrated into VTK.

---

<div class="post-metadata">

### Author: ![cpinter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/cpinter/32/7995_2.png) [@cpinter](https://discourse.slicer.org/u/cpinter)
#### Post date: [May 25, 2021, 12:17pm UTC](https://discourse.slicer.org/t/slicer-build-takes-too-much-time-to-compile-using-make-command/15828/6 "2021-05-25T12:17:40Z")

</div>

> [@lassoan](#):
>
> As an experiment, I’ve implemented proof-of-concept pre-fetching and caching of all file paths in include directories in vtkWrapHierarchy, which made update of hierarchy files about 4-5x faster in debug mode

Wow Andras this would be great if it could be accepted in VTK. Thanks a lot for working on this!

---

<div class="post-metadata">

### Author: ![robertsoakes](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/robertsoakes/32/11042_2.png) [@robertsoakes](https://discourse.slicer.org/u/robertsoakes)
#### Post date: [May 25, 2021, 3:17pm UTC](https://discourse.slicer.org/t/slicer-build-takes-too-much-time-to-compile-using-make-command/15828/7 "2021-05-25T15:17:02Z")

</div>

Thank you for digging into this. Your description of the problem makes a lot of sense and tracks with the (endless) `cmake` output I was seeing.

For the problem I was trying to fix, I was able to determine that it only affected Python code, so I edited the files in the build folder and then ported the new code to the source folder after I was sure it worked. A little annoying, but good enough that I was able to complete and test my patch.

Slicer is an enormous and complex application, and it’s taken me a couple of days to get familiar enough with everything to where I can make contributions. Finding a workflow for Python files that didn’t incur a 20 or 30 minute build time was the last piece of the puzzle I couldn’t quite figure out. (Your documentation, BTW, is wonderful and has been very helpful.) An efficient cache would be absolutely fantastic and would greatly facilitate a streamlined development process.

---

<div class="post-metadata">

### Author: ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)
#### Post date: [May 25, 2021, 5:56pm UTC](https://discourse.slicer.org/t/slicer-build-takes-too-much-time-to-compile-using-make-command/15828/8 "2021-05-25T17:56:56Z")

</div>

> [@robertsoakes](#):
>
> Slicer is an enormous and complex application, and it’s taken me a couple of days to get familiar enough with everything to where I can make contributions

Finding your way around in a way days is outstanding.

It is interesting to note that Slicer is big in the sense that it integrates large libraries and frameworks (Qt, VTK, ITK, Python, …), but compared to these external libraries, Slicer core is relatively small.

> [@cpinter](#):
>
> Wow Andras this would be great if it could be accepted in VTK. Thanks a lot for working on this!

I’ve started a discussion about this on the VTK forum:

> **[Python wrapping is slow on Windows](https://discourse.vtk.org/t/python-wrapping-is-slow-on-windows/5862)**
>
> We use VTK’s Python wrapper for VTK classes in 3D Slicer and we find that on Windows it can take several minutes to generate the hierarchy files for each larger library. If we change a header file at lower level, hierarchy generation can add 10...

I’ve also found a very important other bug in the dependency check mechanism of hierarchy files generation! Hierarchy files are kept regenerated if VTK is updated after the hierarchy files are generated. The workaround is to delete all `*Hierarchy.txt` files in `C:\S4R\Slicer-build`. See details here:

> <https://github.com/Slicer/vtkAddon/issues/22>
>
> We experienced huge slowdowns of application builds due to vtkWrapHierarchy kept… rebuilding hierarchy files. For example, Slicer build took 10 minutes when nothing changed.
> 
> It turned out that this was because VTK was updated after the application was built (which is very common on developer computers). This update updated the vtkWrapHierarchy.exe file's timestamp, which is a \[dependency of hierarchy file generation build step\](https://github.com/Slicer/vtkAddon/blob/5f040632f8222a71b1eb3564a10ae602bcaf5f94/CMake/vtkWrapHierarchy.cmake#L156-L160). Therefore it triggers rebuilding of hierarchy file. However, the content of the hierarchy file was not changed and therefore its timestamp remained the same (older than timestamp of vtkWrapHierarchy.exe). This means that next time the hierarchy got updated again.
> 
> One solution could be vtkWrapHierarchy.cmake should be updated to touch some timestamp file each time vtkWrapHierarchy.exe was executed and use that to determine if the target is up-to-date (rather than use the timestamp of the hierarchy file).
> 
> Another solution could be to force writing of hierarchy files (update their timestamp) even if the file has not changed. Currently, \[vtkWrapHierarchy only updates the output hierarchy file if its content has changed\](https://github.com/Kitware/VTK/blob/37102d559386dcec314775b7dfaa1b317f3b7d7e/Wrapping/Tools/vtkWrapHierarchy.c#L964).
> 
> \*\*Workaround to speed up builds after a VTK update\*\*: delete all the \`\*Hierarchy.txt\` files (for example, in c:\\D\\S4R\\Slicer-build).

---

<div class="post-metadata">

### Author: ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)
#### Post date: [May 29, 2021, 1:13pm UTC](https://discourse.slicer.org/t/slicer-build-takes-too-much-time-to-compile-using-make-command/15828/9 "2021-05-29T13:13:32Z")

</div>

The fix to avoid unnecessary \*Hierarchy.txt files generation has been [integrated in to Slicer](https://github.com/Slicer/vtkAddon/commit/8b5c4b2336a4d2d2aaafe87db3642b5302ddcaa5).

Following my proof-of-concept prototype, David Gobbi has [updated the Python wrapper](https://gitlab.kitware.com/vtk/vtk/-/merge_requests/8026) to make \*Hierarchy.txt file generation many times faster. It is expected to be integrated into VTK in the coming weeks and we’ll backport that fix into Slicer’s VTK.

---

<div class="post-metadata">

### Author: ![upupming](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/upupming/32/12092_2.png) [@upupming](https://discourse.slicer.org/u/upupming)
#### Post date: [August 24, 2021, 9:25am UTC](https://discourse.slicer.org/t/slicer-build-takes-too-much-time-to-compile-using-make-command/15828/10 "2021-08-24T09:25:07Z")

</div>

I found in each rebuild of Slicer, it will take around 1 hour on VTK building, and the logs looks like the following:

```auto
[build] Python Wrapping - generating vtkSQLiteQueryPython.cxx
[build] Python Wrapping - generating vtkSQLiteToTableReaderPython.cxx
[build] Python Wrapping - generating vtkTableToSQLiteWriterPython.cxx
[build] Python Wrapping - generating vtkThreadedImageWriterPython.cxx
[build] Python Wrapping - generating vtkEnSight6BinaryReaderPython.cxx
[build] Python Wrapping - generating vtkEnSight6ReaderPython.cxx
[build] Python Wrapping - generating vtkEnSightGoldBinaryReaderPython.cxx
[build] Python Wrapping - generating vtkEnSightGoldReaderPython.cxx
[build] Python Wrapping - generating vtkEnSightMasterServerReaderPython.cxx
[build] Python Wrapping - generating vtkEnSightReaderPython.cxx
[build] Python Wrapping - generating vtkGenericEnSightReaderPython.cxx
[build] Python Wrapping - generating vtkCPExodusIIElementBlockPython.cxx
[build] Python Wrapping - generating vtkCPExodusIIInSituReaderPython.cxx
[build] Python Wrapping - generating vtkCPExodusIINodalCoordinatesTemplatePython.cxx
[build] Python Wrapping - generating vtkCPExodusIIResultsArrayTemplatePython.cxx
[build] Python Wrapping - generating vtkExodusIICachePython.cxx
[build] Python Wrapping - generating vtkExodusIIReaderPython.cxx
[build] Python Wrapping - generating vtkExodusIIReaderParserPython.cxx
[build] Python Wrapping - generating vtkExodusIIWriterPython.cxx
[build] Python Wrapping - generating vtkModelMetadataPython.cxx
[build] Python Wrapping - generating vtkAVSucdReaderPython.cxx
[build] Python Wrapping - generating vtkBYUReaderPython.cxx
[build] Python Wrapping - generating vtkBYUWriterPython.cxx
[build] Python Wrapping - generating vtkChacoReaderPython.cxx
[build] Python Wrapping - generating vtkFacetWriterPython.cxx
[build] Python Wrapping - generating vtkFLUENTReaderPython.cxx
[build] Python Wrapping - generating vtkGAMBITReaderPython.cxx
[build] Python Wrapping - generating vtkGaussianCubeReaderPython.cxx
[build] Python Wrapping - generating vtkHoudiniPolyDataWriterPython.cxx
[build] Python Wrapping - generating vtkIVWriterPython.cxx
[build] Python Wrapping - generating vtkMCubesReaderPython.cxx
[build] Python Wrapping - generating vtkMCubesWriterPython.cxx
[build] Python Wrapping - generating vtkMFIXReaderPython.cxx
[build] Python Wrapping - generating vtkMoleculeReaderBasePython.cxx
[build] Python Wrapping - generating vtkOBJReaderPython.cxx
[build] Python Wrapping - generating vtkOBJWriterPython.cxx
[build] Python Wrapping - generating vtkOpenFOAMReaderPython.cxx
[build] Python Wrapping - generating vtkParticleReaderPython.cxx
[build] Python Wrapping - generating vtkPDBReaderPython.cxx
[build] Python Wrapping - generating vtkProStarReaderPython.cxx
[build] Python Wrapping - generating vtkPTSReaderPython.cxx
[build] Python Wrapping - generating vtkSTLReaderPython.cxx
[build] Python Wrapping - generating vtkSTLWriterPython.cxx
[build] Python Wrapping - generating vtkTecplotReaderPython.cxx
[build] Python Wrapping - generating vtkWindBladeReaderPython.cxx
[build] Python Wrapping - generating vtkXYZMolReaderPython.cxx
[build] Python Wrapping - generating vtkLSDynaPartPython.cxx
[build] Python Wrapping - generating vtkLSDynaPartCollectionPython.cxx
[build] Python Wrapping - generating vtkLSDynaReaderPython.cxx
[build] Python Wrapping - generating vtkLSDynaSummaryParserPython.cxx
[build] Python Wrapping - generating LSDynaMetaDataPython.cxx
[build] Python Wrapping - generating LSDynaFamilyPython.cxx
[build] Python Wrapping - generating vtkGenericMovieWriterPython.cxx
[build] Python Wrapping - generating vtkOggTheoraWriterPython.cxx
[build] Python Wrapping - generating vtkAVIWriterPython.cxx
[build] Python Wrapping - generating vtkMPASReaderPython.cxx
[build] Python Wrapping - generating vtkNetCDFCAMReaderPython.cxx
[build] Python Wrapping - generating vtkNetCDFCFReaderPython.cxx
[build] Python Wrapping - generating vtkNetCDFPOPReaderPython.cxx
[build] Python Wrapping - generating vtkNetCDFReaderPython.cxx
[build] Python Wrapping - generating vtkSLACParticleReaderPython.cxx
[build] Python Wrapping - generating vtkSLACReaderPython.cxx
[build] Python Wrapping - generating vtkPLYPython.cxx
[build] Python Wrapping - generating vtkPLYReaderPython.cxx
[build] Python Wrapping - generating vtkPLYWriterPython.cxx
[build] Python Wrapping - generating vtkSegYReaderPython.cxx
[build] Python Wrapping - generating vtkSegYIOUtilsPython.cxx
[build] Python Wrapping - generating vtkSegYReaderInternalPython.cxx
[build] Python Wrapping - generating vtkSegYTraceReaderPython.cxx
[build] Python Wrapping - generating vtkVeraOutReaderPython.cxx
[build] Python Wrapping - generating vtkVideoSourcePython.cxx
[build] Python Wrapping - generating vtkWin32VideoSourcePython.cxx
[build] Python Wrapping - generating vtkIOKitPythonInit.cxx
[build] LSDynaFamilyPython.cxx
[build] LSDynaMetaDataPython.cxx
[build] vtkASCIITextCodecPython.cxx
[build] vtkAVIWriterPython.cxx
[build] vtkAVSucdReaderPython.cxx
[build] vtkAbstractParticleWriterPython.cxx
[build] vtkAbstractPolyDataReaderPython.cxx
[build] vtkArrayDataReaderPython.cxx
[build] vtkArrayDataWriterPython.cxx
[build] vtkArrayReaderPython.cxx
[build] vtkArrayWriterPython.cxx
[build] vtkBMPReaderPython.cxx
[build] vtkBMPWriterPython.cxx
[build] vtkBYUReaderPython.cxx
[build] vtkBYUWriterPython.cxx
[build] vtkBase64InputStreamPython.cxx
[build] vtkBase64OutputStreamPython.cxx
[build] vtkBase64UtilitiesPython.cxx
[build] vtkCPExodusIIElementBlockPython.cxx
[build] vtkCPExodusIIInSituReaderPython.cxx
[build] Generating Code...
[build] Compiling...
[build] vtkCPExodusIINodalCoordinatesTemplatePython.cxx
[build] vtkCPExodusIIResultsArrayTemplatePython.cxx
[build] vtkChacoReaderPython.cxx
[build] vtkCompositeDataReaderPython.cxx
[build] vtkCompositeDataWriterPython.cxx
[build] vtkDEMReaderPython.cxx
[build] vtkDICOMImageReaderPython.cxx
[build] vtkDataCompressorPython.cxx
[build] vtkDataObjectReaderPython.cxx
[build] vtkDataObjectWriterPython.cxx
[build] vtkDataReaderPython.cxx
[build] vtkDataSetReaderPython.cxx
[build] vtkDataSetWriterPython.cxx
[build] vtkDataWriterPython.cxx
[build] vtkDatabaseToTableReaderPython.cxx
[build] vtkDelimitedTextWriterPython.cxx
[build] vtkEnSight6BinaryReaderPython.cxx
[build] vtkEnSight6ReaderPython.cxx
[build] vtkEnSightGoldBinaryReaderPython.cxx
[build] vtkEnSightGoldReaderPython.cxx
[build] Generating Code...
[build] Compiling...
[build] vtkEnSightMasterServerReaderPython.cxx
[build] vtkEnSightReaderPython.cxx
[build] vtkExodusIICachePython.cxx
[build] vtkExodusIIReaderParserPython.cxx
[build] vtkExodusIIReaderPython.cxx
[build] vtkExodusIIWriterPython.cxx
[build] vtkFLUENTReaderPython.cxx
[build] vtkFacetWriterPython.cxx
[build] vtkGAMBITReaderPython.cxx
[build] vtkGESignaReaderPython.cxx
[build] vtkGaussianCubeReaderPython.cxx
[build] vtkGenericDataObjectReaderPython.cxx
[build] vtkGenericDataObjectWriterPython.cxx
[build] vtkGenericEnSightReaderPython.cxx
[build] vtkGenericMovieWriterPython.cxx
[build] vtkGlobFileNamesPython.cxx
[build] vtkGraphReaderPython.cxx
[build] vtkGraphWriterPython.cxx
[build] vtkHoudiniPolyDataWriterPython.cxx
[build] vtkIOKitPythonInitImpl.cxx
[build] Generating Code...
[build] Compiling...
[build] vtkIVWriterPython.cxx
[build] vtkImageExportPython.cxx
[build] vtkImageImportExecutivePython.cxx
[build] vtkImageImportPython.cxx
[build] vtkImageReader2CollectionPython.cxx
[build] vtkImageReader2FactoryPython.cxx
[build] vtkImageReader2Python.cxx
[build] vtkImageReaderPython.cxx
[build] vtkImageWriterPython.cxx
[build] vtkInputStreamPython.cxx
[build] vtkJPEGReaderPython.cxx
[build] vtkJPEGWriterPython.cxx
[build] vtkJSONImageWriterPython.cxx
[build] vtkJavaScriptDataWriterPython.cxx
[build] vtkLSDynaPartCollectionPython.cxx
[build] vtkLSDynaPartPython.cxx
[build] vtkLSDynaReaderPython.cxx
[build] vtkLSDynaSummaryParserPython.cxx
[build] vtkLZ4DataCompressorPython.cxx
[build] vtkLZMADataCompressorPython.cxx
[build] Generating Code...
[build] Compiling...
[build] vtkMCubesReaderPython.cxx
[build] vtkMCubesWriterPython.cxx
[build] vtkMFIXReaderPython.cxx
[build] vtkMPASReaderPython.cxx
[build] vtkMRCReaderPython.cxx
[build] vtkMedicalImagePropertiesPython.cxx
[build] vtkMedicalImageReader2Python.cxx
[build] vtkMetaImageReaderPython.cxx
[build] vtkMetaImageWriterPython.cxx
[build] vtkModelMetadataPython.cxx
[build] vtkMoleculeReaderBasePython.cxx
[build] vtkNIFTIImageHeaderPython.cxx
[build] vtkNIFTIImageReaderPython.cxx
[build] vtkNIFTIImageWriterPython.cxx
[build] vtkNetCDFCAMReaderPython.cxx
[build] vtkNetCDFCFReaderPython.cxx
[build] vtkNetCDFPOPReaderPython.cxx
[build] vtkNetCDFReaderPython.cxx
[build] vtkNrrdReaderPython.cxx
[build] vtkNumberToStringPython.cxx
[build] Generating Code...
[build] Compiling...
[build] vtkOBJReaderPython.cxx
[build] vtkOBJWriterPython.cxx
[build] vtkOggTheoraWriterPython.cxx
[build] vtkOpenFOAMReaderPython.cxx
[build] vtkOutputStreamPython.cxx
[build] vtkPDBReaderPython.cxx
[build] vtkPLYPython.cxx
[build] vtkPLYReaderPython.cxx
[build] vtkPLYWriterPython.cxx
[build] vtkPNGReaderPython.cxx
[build] vtkPNGWriterPython.cxx
[build] vtkPNMReaderPython.cxx
[build] vtkPNMWriterPython.cxx
[build] vtkPTSReaderPython.cxx
[build] vtkParticleReaderPython.cxx
[build] vtkPixelExtentIOPython.cxx
[build] vtkPolyDataReaderPython.cxx
[build] vtkPolyDataWriterPython.cxx
[build] vtkPostScriptWriterPython.cxx
[build] vtkProStarReaderPython.cxx
[build] Generating Code...
[build] Compiling...
[build] vtkRTXMLPolyDataReaderPython.cxx
[build] vtkRectilinearGridReaderPython.cxx
[build] vtkRectilinearGridWriterPython.cxx
[build] vtkRowQueryPython.cxx
[build] vtkRowQueryToTablePython.cxx
[build] vtkSLACParticleReaderPython.cxx
[build] vtkSLACReaderPython.cxx
[build] vtkSLCReaderPython.cxx
[build] vtkSQLDatabasePython.cxx
[build] vtkSQLDatabaseSchemaPython.cxx
[build] vtkSQLDatabaseTableSourcePython.cxx
[build] vtkSQLQueryPython.cxx
[build] vtkSQLiteDatabasePython.cxx
[build] vtkSQLiteQueryPython.cxx
[build] vtkSQLiteToTableReaderPython.cxx
[build] vtkSTLReaderPython.cxx
[build] vtkSTLWriterPython.cxx
[build] vtkSegYIOUtilsPython.cxx
[build] vtkSegYReaderInternalPython.cxx
[build] vtkSegYReaderPython.cxx
[build] Generating Code...
[build] Compiling...
[build] vtkSegYTraceReaderPython.cxx
[build] vtkSimplePointsReaderPython.cxx
[build] vtkSimplePointsWriterPython.cxx
[build] vtkSortFileNamesPython.cxx
[build] vtkStructuredGridReaderPython.cxx
[build] vtkStructuredGridWriterPython.cxx
[build] vtkStructuredPointsReaderPython.cxx
[build] vtkStructuredPointsWriterPython.cxx
[build] vtkTIFFReaderPython.cxx
[build] vtkTIFFWriterPython.cxx
[build] vtkTableReaderPython.cxx
[build] vtkTableToDatabaseWriterPython.cxx
[build] vtkTableToSQLiteWriterPython.cxx
[build] vtkTableWriterPython.cxx
[build] vtkTecplotReaderPython.cxx
[build] vtkTextCodecFactoryPython.cxx
[build] vtkTextCodecPython.cxx
[build] vtkThreadedImageWriterPython.cxx
[build] vtkTreeReaderPython.cxx
[build] vtkTreeWriterPython.cxx
[build] Generating Code...
[build] Compiling...
[build] vtkUTF16TextCodecPython.cxx
[build] vtkUTF8TextCodecPython.cxx
[build] vtkUnstructuredGridReaderPython.cxx
[build] vtkUnstructuredGridWriterPython.cxx
[build] vtkVeraOutReaderPython.cxx
[build] vtkVideoSourcePython.cxx
[build] vtkVolume16ReaderPython.cxx
[build] vtkVolumeReaderPython.cxx
[build] vtkWin32VideoSourcePython.cxx
[build] vtkWindBladeReaderPython.cxx
[build] vtkWriterPython.cxx
[build] vtkXMLCompositeDataReaderPython.cxx
[build] vtkXMLCompositeDataWriterPython.cxx
[build] vtkXMLDataObjectWriterPython.cxx
[build] vtkXMLDataParserPython.cxx
[build] vtkXMLDataReaderPython.cxx
[build] vtkXMLDataSetWriterPython.cxx
[build] vtkXMLFileReadTesterPython.cxx
[build] vtkXMLGenericDataObjectReaderPython.cxx
[build] vtkXMLHierarchicalBoxDataFileConverterPython.cxx
[build] Generating Code...
[build] Compiling...
[build] vtkXMLHierarchicalBoxDataReaderPython.cxx
[build] vtkXMLHierarchicalBoxDataWriterPython.cxx
[build] vtkXMLHierarchicalDataReaderPython.cxx
[build] vtkXMLHyperTreeGridReaderPython.cxx
[build] vtkXMLHyperTreeGridWriterPython.cxx
[build] vtkXMLImageDataReaderPython.cxx
[build] vtkXMLImageDataWriterPython.cxx
[build] vtkXMLMultiBlockDataReaderPython.cxx
[build] vtkXMLMultiBlockDataWriterPython.cxx
[build] vtkXMLMultiGroupDataReaderPython.cxx
[build] vtkXMLPDataObjectReaderPython.cxx
[build] vtkXMLPDataReaderPython.cxx
[build] vtkXMLPImageDataReaderPython.cxx
[build] vtkXMLPPolyDataReaderPython.cxx
[build] vtkXMLPRectilinearGridReaderPython.cxx
[build] vtkXMLPStructuredDataReaderPython.cxx
[build] vtkXMLPStructuredGridReaderPython.cxx
[build] vtkXMLPTableReaderPython.cxx
[build] vtkXMLPUnstructuredDataReaderPython.cxx
[build] vtkXMLPUnstructuredGridReaderPython.cxx
[build] Generating Code...
[build] Compiling...
[build] vtkXMLParserPython.cxx
[build] vtkXMLPartitionedDataSetCollectionReaderPython.cxx
[build] vtkXMLPartitionedDataSetCollectionWriterPython.cxx
[build] vtkXMLPartitionedDataSetReaderPython.cxx
[build] vtkXMLPartitionedDataSetWriterPython.cxx
[build] vtkXMLPolyDataReaderPython.cxx
[build] vtkXMLPolyDataWriterPython.cxx
[build] vtkXMLReaderPython.cxx
[build] vtkXMLRectilinearGridReaderPython.cxx
[build] vtkXMLRectilinearGridWriterPython.cxx
[build] vtkXMLStructuredDataReaderPython.cxx
[build] vtkXMLStructuredDataWriterPython.cxx
[build] vtkXMLStructuredGridReaderPython.cxx
[build] vtkXMLStructuredGridWriterPython.cxx
[build] vtkXMLTableReaderPython.cxx
[build] vtkXMLTableWriterPython.cxx
[build] vtkXMLUniformGridAMRReaderPython.cxx
[build] vtkXMLUniformGridAMRWriterPython.cxx
[build] vtkXMLUnstructuredDataReaderPython.cxx
[build] vtkXMLUnstructuredDataWriterPython.cxx
[build] Generating Code...
[build] Compiling...
[build] vtkXMLUnstructuredGridReaderPython.cxx
[build] vtkXMLUnstructuredGridWriterPython.cxx
[build] vtkXMLUtilitiesPython.cxx
[build] vtkXMLWriterCPython.cxx
[build] vtkXMLWriterPython.cxx
[build] vtkXYZMolReaderPython.cxx
[build] vtkZLibDataCompressorPython.cxx
[build] Generating Code...
[build] Creating library C:/D/S4/out/build/RelWithDebInfo/VTK-build/lib/Debug/vtkIOKitPython36D-8.2.lib and object C:/D/S4/out/build/RelWithDebInfo/VTK-build/lib/Debug/vtkIOKitPython36D-8.2.exp
[build] vtkIOKitPythonD.vcxproj -> C:\D\S4\out\build\RelWithDebInfo\VTK-build\bin\Debug\vtkIOKitPython36D-8.2.dll
[build] Python Wrapping - generating vtkAddMembershipArrayPython.cxx
[build] Python Wrapping - generating vtkAdjacencyMatrixToEdgeTablePython.cxx
[build] Python Wrapping - generating vtkArrayNormPython.cxx
[build] Python Wrapping - generating vtkArrayToTablePython.cxx
[build] Python Wrapping - generating vtkCollapseGraphPython.cxx
[build] Python Wrapping - generating vtkCollapseVerticesByArrayPython.cxx
[build] Python Wrapping - generating vtkContinuousScatterplotPython.cxx
[build] Python Wrapping - generating vtkDataObjectToTablePython.cxx
[build] Python Wrapping - generating vtkDotProductSimilarityPython.cxx
[build] Python Wrapping - generating vtkExtractSelectedTreePython.cxx
[build] Python Wrapping - generating vtkEdgeCentersPython.cxx
[build] Python Wrapping - generating vtkExpandSelectedGraphPython.cxx
[build] Python Wrapping - generating vtkExtractSelectedGraphPython.cxx
[build] Python Wrapping - generating vtkGenerateIndexArrayPython.cxx
[build] Python Wrapping - generating vtkGraphHierarchicalBundleEdgesPython.cxx
[build] Python Wrapping - generating vtkGroupLeafVerticesPython.cxx
[build] Python Wrapping - generating vtkMergeColumnsPython.cxx
[build] Python Wrapping - generating vtkMergeGraphsPython.cxx
[build] Python Wrapping - generating vtkMergeTablesPython.cxx
[build] Python Wrapping - generating vtkMutableGraphHelperPython.cxx
[build] Python Wrapping - generating vtkNetworkHierarchyPython.cxx
[build] Python Wrapping - generating vtkPipelineGraphSourcePython.cxx
[build] Python Wrapping - generating vtkPruneTreeFilterPython.cxx
[build] Python Wrapping - generating vtkRandomGraphSourcePython.cxx
[build] Python Wrapping - generating vtkReduceTablePython.cxx
[build] Python Wrapping - generating vtkRemoveIsolatedVerticesPython.cxx
[build] Python Wrapping - generating vtkSparseArrayToTablePython.cxx
[build] Python Wrapping - generating vtkStreamGraphPython.cxx
[build] Python Wrapping - generating vtkStringToCategoryPython.cxx
[build] Python Wrapping - generating vtkStringToNumericPython.cxx
[build] Python Wrapping - generating vtkTableToArrayPython.cxx
[build] Python Wrapping - generating vtkTableToGraphPython.cxx
[build] Python Wrapping - generating vtkTableToSparseArrayPython.cxx
[build] Python Wrapping - generating vtkTableToTreeFilterPython.cxx
[build] Python Wrapping - generating vtkThresholdGraphPython.cxx
[build] Python Wrapping - generating vtkThresholdTablePython.cxx
[build] Python Wrapping - generating vtkTransferAttributesPython.cxx
[build] Python Wrapping - generating vtkTransposeMatrixPython.cxx
[build] Python Wrapping - generating vtkTreeFieldAggregatorPython.cxx
[build] Python Wrapping - generating vtkTreeDifferenceFilterPython.cxx
[build] Python Wrapping - generating vtkTreeLevelsFilterPython.cxx
[build] Python Wrapping - generating vtkVertexDegreePython.cxx
[build] Python Wrapping - generating vtkRemoveHiddenDataPython.cxx
[build] Python Wrapping - generating vtkKCoreDecompositionPython.cxx
[build] Python Wrapping - generating vtkInfovisCorePythonInit.cxx
[build] vtkAddMembershipArrayPython.cxx
[build] vtkAdjacencyMatrixToEdgeTablePython.cxx
[build] vtkArrayNormPython.cxx
[build] vtkArrayToTablePython.cxx
[build] vtkCollapseGraphPython.cxx
[build] vtkCollapseVerticesByArrayPython.cxx
[build] vtkContinuousScatterplotPython.cxx
[build] vtkDataObjectToTablePython.cxx
[build] vtkDotProductSimilarityPython.cxx
[build] vtkEdgeCentersPython.cxx
[build] vtkExpandSelectedGraphPython.cxx
[build] vtkExtractSelectedGraphPython.cxx
[build] vtkExtractSelectedTreePython.cxx
[build] vtkGenerateIndexArrayPython.cxx
[build] vtkGraphHierarchicalBundleEdgesPython.cxx
[build] vtkGroupLeafVerticesPython.cxx
[build] vtkInfovisCorePythonInitImpl.cxx
[build] vtkKCoreDecompositionPython.cxx
[build] vtkMergeColumnsPython.cxx
[build] vtkMergeGraphsPython.cxx
[build] Generating Code...
[build] Compiling...
[build] vtkMergeTablesPython.cxx
[build] vtkMutableGraphHelperPython.cxx
[build] vtkNetworkHierarchyPython.cxx
[build] vtkPipelineGraphSourcePython.cxx
[build] vtkPruneTreeFilterPython.cxx
[build] vtkRandomGraphSourcePython.cxx
[build] vtkReduceTablePython.cxx
[build] vtkRemoveHiddenDataPython.cxx
[build] vtkRemoveIsolatedVerticesPython.cxx
[build] vtkSparseArrayToTablePython.cxx
[build] vtkStreamGraphPython.cxx
[build] vtkStringToCategoryPython.cxx
[build] vtkStringToNumericPython.cxx
[build] vtkTableToArrayPython.cxx
[build] vtkTableToGraphPython.cxx
[build] vtkTableToSparseArrayPython.cxx
[build] vtkTableToTreeFilterPython.cxx
[build] vtkThresholdGraphPython.cxx
[build] vtkThresholdTablePython.cxx
[build] vtkTransferAttributesPython.cxx
[build] Generating Code...
[build] Compiling...
[build] vtkTransposeMatrixPython.cxx
[build] vtkTreeDifferenceFilterPython.cxx
[build] vtkTreeFieldAggregatorPython.cxx
[build] vtkTreeLevelsFilterPython.cxx
[build] vtkVertexDegreePython.cxx
[build] Generating Code...
[build] Creating library C:/D/S4/out/build/RelWithDebInfo/VTK-build/lib/Debug/vtkInfovisCorePython36D-8.2.lib and object C:/D/S4/out/build/RelWithDebInfo/VTK-build/lib/Debug/vtkInfovisCorePython36D-8.2.exp
[build] vtkInfovisCorePythonD.vcxproj -> C:\D\S4\out\build\RelWithDebInfo\VTK-build\bin\Debug\vtkInfovisCorePython36D-8.2.dll
[build] Python Wrapping - generating vtkAbstractMapper3DPython.cxx
[build] Python Wrapping - generating vtkAbstractMapperPython.cxx
[build] Python Wrapping - generating vtkAbstractPickerPython.cxx
[build] Python Wrapping - generating vtkAbstractVolumeMapperPython.cxx
[build] Python Wrapping - generating vtkActor2DCollectionPython.cxx
[build] Python Wrapping - generating vtkActor2DPython.cxx
[build] Python Wrapping - generating vtkActorCollectionPython.cxx
[build] Python Wrapping - generating vtkActorPython.cxx
[build] Python Wrapping - generating vtkAssemblyPython.cxx
[build] Python Wrapping - generating vtkBackgroundColorMonitorPython.cxx
[build] Python Wrapping - generating vtkBillboardTextActor3DPython.cxx
[build] Python Wrapping - generating vtkCameraActorPython.cxx
[build] Python Wrapping - generating vtkCameraPython.cxx
[build] Python Wrapping - generating vtkCameraInterpolatorPython.cxx
[build] Python Wrapping - generating vtkCellCenterDepthSortPython.cxx
[build] Python Wrapping - generating vtkCIEDE2000Python.cxx
[build] Python Wrapping - generating vtkColorTransferFunctionPython.cxx
[build] Python Wrapping - generating vtkCompositeDataDisplayAttributesPython.cxx
[build] Python Wrapping - generating vtkCompositeDataDisplayAttributesLegacyPython.cxx
[build] Python Wrapping - generating vtkCompositePolyDataMapperPython.cxx
[build] Python Wrapping - generating vtkCoordinatePython.cxx

```

This is the most time-consuming step during rebuild of Slicer, is there anyway can I reduce the rebuild time?

The build command I used is:

```auto
"C:\Program Files\CMake\bin\cmake.EXE" --build c:/D/S4/out/build/RelWithDebInfo --parallel 12

```

---

<div class="post-metadata">

### Author: ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)
#### Post date: [August 24, 2021, 12:55pm UTC](https://discourse.slicer.org/t/slicer-build-takes-too-much-time-to-compile-using-make-command/15828/11 "2021-08-24T12:55:02Z")

</div>

This happens because a VTK bug that always rebuilds hierarchy files if the build was not clean and very slow check in the VTK Python wrapper if a file exists. With help from David Gobbi, we fixed both issues in VTK about a month ago, but we have not yet backported these improvements into Slicer.

You can fix the first problem quite easily:

1. Rebuild Slicer (including all dependencies) completely from scratch, from a clean build folder.
2. If you just change Slicer and its modules, don’t build the top-level folder (c:\D\S4R\Slicer.sln), which builds all the dependencies, only the inner-build (c:\D\S4R\Slicer-build\Slicer.sln)

We’ll soon rebase Slicer’s VTK on the latest VTK master, which will speed up hierarchy file generation several times faster.

---

<div class="post-metadata">

### Author: ![upupming](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/upupming/32/12092_2.png) [@upupming](https://discourse.slicer.org/u/upupming)
#### Post date: [August 24, 2021, 12:56pm UTC](https://discourse.slicer.org/t/slicer-build-takes-too-much-time-to-compile-using-make-command/15828/12 "2021-08-24T12:56:38Z")

</div>

Thanks for pointing it out. Nice to see you are going to rebase the new VTK version! I will try the two methods to see how they change the build time.
