[Interest] Compile Speed Question regarding MOC

Michael Jackson imikejackson at gmail.com
Wed Feb 19 04:14:45 CET 2014


On Feb 18, 2014, at 7:48 PM, Tony Rietwyk <tony at rightsoft.com.au> wrote:

> Mike wrote:
> 
>> Sent: Wednesday, 19 February 2014 9:05 AM
>> 
>> I have what seems to be an obvious question/answer but the subtleties may
>> not be what I think they are. We have a project with about 500 files most
> of
>> which inherit from QObject or QWidget which means they all have moc run
>> on them. Currently I have each moc created file compiled as a separate
>> object which means for every class I have I am really compiling 2 files
> (.cpp
>> and mocXXXX.cxx). The compile times are starting to get "up there" a bit
> and
>> I was wondering what others do at this point? Do you simply do the
> #include
>> "moc_MyClass.cxx" in the .cpp file of MyClass? Does that really help speed
>> up the compile process? Before I go updating all of our source files I
> just
>> wanted to get a quick sanity check for this course of action from the Qt
>> community.
>> 
>> Thanks for any advice.
>> Mike Jackson
> 
> I had the same problem, and use qmake to generate VS, XCode and Make
> projects.  I noticed the Qt sources include the moc in each .cpp.   I
> changed my code to do the same and it works well.   The qmake utility
> recognises this and does not create a separate compile step for them.   Of
> course the real solution is to get a faster machine.  
> 
> Regards, 
> 
> Tony

Thanks everyone for the feedback. I just wanted to make sure I was not going to fall into some esoteric trap or something. I use CMake for my projects so I went ahead and enabled the AUTOMOC feature and it seems to be build just find now. Again, thanks for the help.

Mike Jackson




More information about the Interest mailing list