Back to Blog home

Qt Commercial Support Weekly #5: qmake and Giving Mac Some Love

Published on Tuesday November 29, 2011 by Andy Shaw in Uncategorized | Comments

As I have mentioned before in previous support weeklies, qmake is a powerful and useful tool. It is also one close to my heart as I have worked a lot on it in the past including the XCode 4 support that was done recently.

 

What came up recently in support is someone who wanted to provide a way to ensure that something was always recompiled when an application was built.  To do this manually you would need to do:

  touch main.cpp
  make

 

But, this is always prone to errors as you may forget to do the touch and also this case may be a rather simplified version of what you want to do with each build.  Luckily, what you can do is utilize the QMAKE_EXTRA_TARGETS directive and the PRE_TARGETDEPS variable inside your pro file to set something up.

 

QMAKE_EXTRA_TARGETS is useful for adding extra targets to your Makefiles so you can have something that builds a different part or does some other commands, but for this case we will just have a command that touches the main.cpp for us.  So the following can be done to do this:

 

updatemain.commands = touch main.cpp

QMAKE_EXTRA_TARGETS += updatemain

 

The commands part can contain whatever you want to do inside the target, then we just add the extra target to the list of QMAKE_EXTRA_TARGETS.  All that is left for us to do now is to ensure this is done before the target is built and thus ensure it gets recompiled.  To do this we add the extra target to the PRE_TARGETDEPS variable like:

 

PRE_TARGETDEPS += updatemain

 

After rerunning qmake it will invoke the updatemain.commands for us each time we make.

 

In other areas this week, we managed to fix a couple of Mac specific issues, one involving clicking on submenu entries in a menu in the menubar.  What would happen is that this would act as if an action had been invoked instead of doing nothing.  The other issue was with palette changes being lost when the application had been deactivated and then reactivated.  Both of these fixes are available via the support team, so just contact us via the Qt Commercial customer portal if you want any of these fixes.

 

Finally, if you happen to be in San Francisco for Qt Developer Days (Nov 29 - Dec 1) then please stop by the support desk and say hello!  I personally won't be there, but there are four eager support engineers waiting to help you with any questions you may have.

Subscribe to Our Blog

Stay up to date with the latest marketing, sales and service tips and news.

The blog comment system has been migrated to a new platform. If you face any issues, please let us know via feedback@qt.io.