[CMake] compile header file for precompiled gcc headers

frederic heem frederic.heem at telsey.it
Mon Dec 18 04:46:39 EST 2006


Hi,
Which version of cmake are you using for precompiled header ?
Here is the ouptut of gcc when compiling headers:
/usr/bin/c++ -I/home/heefre/svn/trunk/voxgratia/opal/include;-I/home/heefre/svn/trunk/voxgratia/ptlib_unix/include;-I/usr/include/xsd;-I/usr/include;-I/home/heefre/svn/trunk/FsmCompiler/language/cpp/include;-I/home/heefre/svn/trunk/voxgratia/OpalTester/include;-I/home/heefre/svn/trunk/voxgratia/OpalTester/src;-I/home/heefre/svn/trunk/voxgratia/OpalTester/build/src;-I/usr/local/Trolltech/Qt-4.2.0/include;-I/usr/local/Trolltech/Qt-4.2.0/include/QtGui;-I/usr/local/Trolltech/Qt-4.2.0/include/QtCore;-I/usr/local/Trolltech/Qt-4.2.0/include/QtDBus;;;-DP_USE_PRAGMA;-D_REENTRANT;;;;;-DPTRACING;-Wall;-Werror;-DQT_GUI_LIB;-DQT_CORE_LIB -x 
c++-header -o /home/heefre/svn/trunk/voxgratia/OpalTester/build/src/std_includes.h.gch/.c++ /home/heefre/svn/trunk/voxgratia/OpalTester/src/std_includes.h
Every argument is separated by a colon, hence the compilation fails
Frederic Heem

On Monday 18 December 2006 9:25 am, Maik Beckmann wrote
> Am Sonntag, den 17.12.2006, 21:55 +0100 schrieb klaas.holwerda:
> > Hi,
> >
> > I want to get gcc to use precompiled headers.
> >  From http://gcc.gnu.org/onlinedocs/gcc/Precompiled-Headers.html
> > i read that i need to compile a header file ( containing #includes to
> > all others for instance ).
> >
> > I have this haeder file, how to compile it with Cmake?
> >
> > I tried CHECK_CXX_SOURCE_COMPILES( wxart2d.h DONNO )
> >
> > But that does not produce a "wxart2d.gch" file.
> >
> > Understand that i do not need to get an executable nor library.
> >
> > Does somebody know how to do it?
> >
> > Has someone already succeeded in using precompiled headers with gcc on
> > Linux, any tips?
> >
> > Thanks,
> >
> > Klaas
>
> Hello
>
> Rosegarden (http://www.rosegardenmusic.com/) uses experimental PCH
> support
> http://rosegarden.svn.sourceforge.net/viewvc/rosegarden/trunk/rosegarden/cm
>ake_admin/FindPCHSupport.cmake?revision=7699&view=markup
>
> This macro works per directory. It adds a target for precompileing the
> header and every C++ source is compiled using it.
>
> I tweaked this version for applying PCH's per target (see attachment)
>
> My version should be used like this:
> <CMakeLists.txt>
>     add_executable(test test.cpp)
>     add_precompiled_header( test std_includes.h)
> </CMakeLists.txt>
>
> It's very experimental, but now my sources using boost.fusion compile
> about 6-8 times faster than without PCH.
>
> MfG Maik


More information about the CMake mailing list