Building QT with Visual Studio multicore on Winblows

Ok you may know I am a (li)nux nut, love to build with GNU etc etc.. and how I am always complaining about having to build for Microsloth. Life is getting easier for me because now there is QT on windows. Well actually its been around for a couple of years but only recently I have had the pleasure of getting other companies involved in this QT mania.

I have been building QT on *nix boxes for ages and because I am not a Winblows man I thought I would share some of my pain for you other folk.

I'm going to be building for Visual Studio 2005 which it's not supported, but hey that's never stopped me.

1.go to the QT repository and get the source you want.

so if I want vers 4.5.1 I would download

2.unzip it
I also like to move the file in a nice dir like C:\QT\4.5.1

open up a Visual Studio Command prompt

3.go to the dir

cd C:\QT\4.5.1

4a.(optional) Now if you run nmake using only a release build like I explain below it's gonna take about 2 hours to compile on a core2 duo! - actually it took mine 2 hours 4 mins with these standard settings.
If you are like me and used to GNU goodness like -q (taking use of multicore) then you are going to want to make this extra tweak.
Just open your visual studio qmake conf

for Visual studio 2005 mkspecs\win32-msvc2005\qmake.conf
for Visual studio 2008 mkspecs\win32-msvc2008\qmake.conf

QMAKE_CFLAGS = -nologo -Zm200 -Zc:wchar_t-
QMAKE_CFLAGS = -nologo -Zm200 -MP -Zc:wchar_t-

oh and yes this DOES work on VS 2005 I know its not documented until VS 2008 but trust me both cores will run!

One drawback is its not as parallel as GNU so using both cores wont get you double the speedup, I got a %23 deduction in build time using 2 cores instead of 1. So from 128 mins to 99 mins. I did try the -MP2 (MP) as stated in Visual Studio 2008 docs however no speedup was gained, using the -MP flag alone the system is supposed to get the number of procs automatically.

4.Configure the makes:
configure.exe -release -no-dsp -vcproj

the release means I'm going to save some time by skipping a debug build, same as skipping the dsp's but generating vcproj(for Visual Studio)

- If you have performed the optional 4a step above you will get a warning from qmake
"WARNING: Could not parse Compiler option: -MP, added as AdditionalOption." qmake doesn't seem to recognize the flag but it will obliviously put it in there for you anyway!

now build her!