Boost logo

Boost-Build :

From: Jürgen Hunold (hunold_at_[hidden])
Date: 2005-09-08 04:55:37


Hi Volodya !

On Dunnersdag 08 September 2005, 11:19, Vladimir Prus wrote:
> Hi Jürgen,

> I'm working on making .cpp files moccable at the moment. My current syntax
> looks like this:
>
> exe main : main.cpp
> [ cast _ moccable-cpp : main.cpp ]
> /qt//qt ;
>
> Where 'moccable-cpp' is a new type of files, needed to indicate that we
> want to invoke moc on them, 'cast' is a new main target, and '_'
> essentially means "I don't want to provide any name".

The name then will be "main.moc", I hope ?

> However, it looks that with moccable .cpp files you *have* to #include
> output of moc.
>
> 1. If generated file does not #include original source file, it won't
> compile because it does not see definitions of classes from .cpp file.
> 2. If generated file #includes original source file, you get multiple
> symbols.
>
> So, you need to add #include "mocced_file.moc" to you .cpp file.

Yes, thats exactly the way qmake works when generating Makefiles.

> That's fine, but so far V2's Qt tool simply compiled the files generated by
> moc, and did not require to #include the result. It will be inconsistent if
> we require #include for moccing .cpp files, and don't require (and in fact
> prohibit) #include for moccing .h files.

Well, please take a look a TrollTechs documents at

http://doc.trolltech.com/4.0/moc.html

and take a look at the section
"Writing Make Rules for Invoking moc".

TT distinguishes between .h and .cpp.
They suggest to moc and compile .h files
and to moc and #include .cpp (implementation) files.

I think we should follow this suggestions because qmake works this way.
And most users willing to switch to bjam will probably either migrate from
qmake or have handwritten Makefiles following these suggestion.

On the other I know that the KDE project _always_ #includes the mocced files
in order to get some speed improvements.
But they are switching to Scons at the moment...

> What will the users say if I change Qt support to always require #including"
> the output of moc?

This user says it will break *every* project I have *ever* worked on.
That's because we use qmake and Visual Studio.

If we want to support both schemes we need a configurable switch in each
Jamroot, IMHO.

Yours,

Jürgen

-- 
* Dipl.-Math. Jürgen Hunold ! Institut für Verkehrswesen, Eisenbahnbau
* voice: ++49 511 762-2529 ! und -betrieb, Universität Hannover 
* fax : ++49 511 762-3001 ! Appelstrasse 9a, D-30167 Hannover
* hunold_at_[hidden] ! www.ive.uni-hannover.de
 

Boost-Build list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk