[Solved] Prevent MOC compilation if .h file is not modified
I'm using qt under microsoft visual Studio 2008. The compilation of my project takes a long time because moc.exe is executed for all .h files even if there are not modified since the last compilation. Is there a way to prevent this ?
I have the same question for ui files. I hope that it's the same solution
welcome to the forum.
Are you using "vsaddin":http://qt.nokia.com/downloads/visual-studio-add-in together with visual studio?
I have noticed similar behaviour before and there are similar posts to be found on devnet. Apparently, there are issues when an .pro file is imported to vs. "Maybe this will help you":http://developer.qt.nokia.com/forums/viewthread/7658/#45053
Thanks for your reply. I'm not using vsaddin. I've added the moc command to the properties of my .h files.
[quote author="mcunha" date="1310997452"] I'm not using vsaddin. I've added the moc command to the properties of my .h files.
This might be the origin of your problem. I am using the vsaddin. It setups different folders for debug and release mocs.
OK I'm going to use it !
Could you tell me waht these 4 settings in the vsAddin options refer to ?
Thanks for your help.
I am a user of vsAddin as you. I can only guess on these definitions. The parameters have never being changed in my setup, at least as I remember. So they should be still the default values.
The first and third setting are probably for some versioning system (e.g. svn).
With the second you may apparently change the mocing behaviour. However, the current setting seem to be fine for my applications. Possibly you have to change to avoid frequent mocing without having changed anything.
The forth is obviously a parameter for lupdate tool.
The only thing I have changed is the MocDirectory and the default version of Qt being used. When you are changing the MocDirectory you may want to have a dependency to the configuration in there
(e.g. .\GeneratedFiles$(PlatformName)$(ConfigurationName) or .\GeneratedFiles$(ConfigurationName) ).
If all this does not cure your problem, you may need to exclude the individual .h file from build. This should prevent the mocing. However, personally, I would not be keen to do so. You need to remember when you have done a change :-(
Thanks a lot for all your remark.
You are welcome.
If this solved your problem, please mark it in the title line with [solved]. This may help others then.