QtCreator and MSVC2015: uses default compiler switches
I recently switched from MinGW to MSVC2015 for my Qt application, mainly in order to be able to build 64bit binaries. I noticed that the 64 bit binaries run slower than with MinGW and 32 bit. So I wanted to play with the various compiler switches to see if I can squeeze a little bit more out. To my surprize I noticed that QtCreator would automatically add compiler switches like following:
-O2 -W34100 -W34189 -W44456, etc.
If I add myself compiler switches in the *.pro file (e.g. with QMAKE_CXXFLAGS += -=O2), then some switches appear as duplicates in the compile output. But that also means that some switches can be in conflict with each other, meaning that finally I am not in control of which switches are applies.
So my question: where are the default compiler switches added to the Qt builds (when building via QtCreator)?
I am using Qt 5.6.1, Qt Creator 4.0.3, MSVC 2015 for 64bit builds)
Thanks for any insight
Flags passed to your toolchain are defined int the
qmake.conffile of the kit you're using. They are placed in the
mkspecsdirectory of your Qt installation. For VS2015 this would be the file
<Qt install dir>/mkspecs/win32-msvc2015/qmake.conf, which includes
<Qt install dir>/mkspecs/common/msvc-desktop.conf. The second one contains the switches you mentioned.
Thanks a lot for your quick reply Chris. Working nicely now!!
@Chris-Kawa I have to ask again a similar question: now I want to remove the /Zc:StrictStrings switch that is automatically set. I need to do this because the code I am compiling generates tons of errors of type C4244, and it wasn't doing this with MinGW. That code is a third-party code and difficult to modify, so I want to remove that switch.
But to my surprise, there is no such switch in the configuration file you suggest, and I am now at a loss how to remove that compiler switch.
Following doesn't work in the *.pro file:
QMAKE_CXXFLAGS_RELEASE -= -ZcstrictStrings
@floatingWoods I think I can answer to myself: <Qt install dir>/mkspecs/common/msvc-desktop.conf contains yet another include file (msvc-base.conf), which contains the switches I was looking for. Sorry for the noise