On Sun, Jun 7, 2009 at 12:07 AM, Robert Dailey<[email protected]> wrote:
> Hey guys,
> First of all I just want to let you guys know that I DID find this in my
> search:
> http://www.cmake.org/pipermail/cmake/2008-May/021483.html
> However, I do not feel as if a direct answer was given. Besides, that was
> over a year ago and I'm hoping some new developments have taken place. Is
> there a portable way of handling PCH files in CMake 2.6.4 or in a
> development/nightly build? If so, how do I enable it? I'm using Visual
> Studio 2008, generated by CMake 2.6.4.
> Thanks.
>

Here is what I do for Vs2005 builds and CMake 2.6.4

I put this in the main CMakeLists.txt before any add_subdirectory(Libraries)

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)



So then to use the macro for a library 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)


You need to then create

laGUIPCH.h
laGUIPCH.cxx

the .cxx file contains any headers that will be not changed often.
This is the same as stdafx.cpp was and the .h file must be included in
every cpp that is in the ${ProjectName}_SRCS list


I hope this makes sense.

John
_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake

Reply via email to