# Precompiled headers to speed up builds

**URL:** <https://discourse.slicer.org/t/precompiled-headers-to-speed-up-builds/37760>\
**Category:** Development\
**Tags:** build\
**Created:** [August 8, 2024, 7:03am UTC](https://discourse.slicer.org/t/precompiled-headers-to-speed-up-builds/37760 "2024-08-08T07:03:58Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![aymeric.chataigner](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/aymeric.chataigner/32/4977_2.png) [@aymeric.chataigner](https://discourse.slicer.org/u/aymeric.chataigner)\
**Post date:** [August 8, 2024, 7:03am UTC](https://discourse.slicer.org/t/precompiled-headers-to-speed-up-builds/37760/1 "2024-08-08T07:03:58Z")

</div>

Hi,

I would like to precompile Qt, Vtk and Itk headers to speed up the build in the Slicer-build directory.

I created some empty libraries in Libs directory to precompile the most common headers (QString, QObject, VtkObject.h…)  
PrecompileItkHeaders  
PrecompileVtkHeaders  
PrecompileQtCoreHeaders  
PrecompileQtWidgetsHeaders

I tried to add some target\_precompile\_headers cmake commands in slicer CMakeLists.txt but most of the time it does not work: this gcc warning appears:  
cmake\_pch.hxx.gch: not used because `PrecompileVtkHeaders\_EXPORTS’ not defined [-Winvalid-pch]

If I use add\_executable rather than add\_library in my Precompile\*\*\* projects then these warnings disappear… But I still have similar warnings if I try to use precompiled headers in loadable modules.

Do you have any experience / guidelines with precompiled headers ?  
Is it in the 3D Slicer roadmap ?

The results are very interesting (Libs/MRML/Widgets build in 20 seconds rather than 2 minutes if I use QtCore and QtWidgets precompiled headers)

Regards
