[CMake] Pre-Compiled Headers
ML
mailinglists at mailnewsrss.com
Thu Aug 20 17:37:53 EDT 2009
John,
Awesome, thanks for both of the e-mails.
-Jason
On Aug 20, 2009, at 2:29 PM, John Drescher wrote:
> On Thu, Aug 20, 2009 at 5:25 PM, ML<mailinglists at mailnewsrss.com>
> wrote:
>> Hi All,
>>
>> I need to use a pre-compiled header.
>>
>> I think that I recall that CMake is not yet equipped to handle this.
>>
>> I found thought a Google search that SET_SOURCE_FILES_PROPERTIES
>> might be
>> the way to go.
>>
>> Has anyone implemented PCH and have an example, advice, etc?
>>
>
> 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.
>
> John
More information about the CMake
mailing list