Page MenuHomePhabricator

Support Precompiled Headers in the build system
Open, WishlistPublic

Description

Precompiled headers can speed up build times considerably. This article says 'up to one order of magnitude': http://gamesfromwithin.com/?p=39

Both GCC and Visual C++ support precompiled headers.

On the CMake mailinglist, a cmake macro for enabling procompiled headers was posted (http://article.gmane.org/gmane.comp.programming.tools.cmake.user/23266) -->

On Thu, Aug 6, 2009 at 2:34 PM, ML<mailinglists@...> wrote:

Hi All,

Can CMAKE use Pre-compiled headers now? I thought that I recalled their
being an issue at some point, not sure.

Can anyone shed some light?

I do this for my Visual Studio builds with a macro.

macro( LA_PCH_SUPPORT ProjectName )
if (MSVC)
if (USE_MSVC_PCH)

		set_source_files_properties(${ProjectName}PCH.cxx
			PROPERTIES
			COMPILE_FLAGS "/Yc${ProjectName}PCH.h"
			)
		foreach( src_file ${${ProjectName}_SRCS} )
			set_source_files_properties(
				${src_file}
				PROPERTIES
				COMPILE_FLAGS "/Yu${ProjectName}PCH.h"
				)
		endforeach( src_file ${${ProjectName}_SRCS} )
		
		list(APPEND ${ProjectName}_SRCS ${ProjectName}PCH.cxx)
		list(APPEND ${ProjectName}_EXT_HDRS ${ProjectName}PCH.h)

endif(USE_MSVC_PCH)
endif (MSVC)
endmacro (LA_PCH_SUPPORT)

Then its usage in a project named laGUI

SET( laGUI_SRCS
./src/laMultiViewFrameMgr.cxx
./src/VTK2dWidget.cpp
./src/laCentralWidget.cxx
./src/laImageSliceView.cxx
./src/laWLWidget.cxx
./src/laTableWidget.cxx
./src/laPipelineWidget.cxx
./src/ImageSliceViewer.cxx
./src/InteractorObserver.cxx
./src/laVTKInteractorStyleImage2D.cxx
./src/laVTKCommandImage2D.cxx
./src/la2DView.cxx
./src/la3DView.cxx
)

SET( laGUI_EXT_HDRS
./Include/InteractorObserver.h
./Include/laVTKInteractorStyleImage2D.h
./Include/laVTKCommandImage2D.h
)

SET( laGUI_MOC_HDRS
./Include/ImageSliceViewer.h
./Include/laMultiViewFrameMgr.h
./Include/VTK2dWidget.h
./Include/laCentralWidget.h
./Include/laImageSliceView.h
./Include/laWLWidget.h
./Include/laTableWidget.h
./Include/laPipelineWidget.h
./Include/la2DView.h
./Include/la3DView.h
)

#Add precompiled header support
LA_PCH_SUPPORT(laGUI)

Then externally create

laGUIPCH.cxx
laGUIPCH.h

in the same folder as the CMakeLists.txt file for the project.

Event Timeline

adding some people with expertise/interest to CC list.

nolden added a subscriber: nolden.Sep 29 2009, 8:20 AM

I can remember we discussed this on the MITK meeting. Any decision?

The decision was that the importance is low, so we keep it in mind, until someone volunteers for it.

Resetting all bugs without active assignee flag to "CONFIRMED". Change status to IN_PROGRESS if you are working on it.