How does QtCreator know when to re-run qmake?



  • I am using QtCreator with qmake-based projects in a git repository. I'd like to use "git describe" to generate a version string, which is easy enough in qmake.

    However, qtcreator doesn't re-run qmake every time I build (nor should it). I would like to know if there is some way I can convince qtcreator to re-run qmake whenever the current git commit ID, branch, or tag changes.

    Any ideas?



  • One possible approach I've come up with is to install a git hook (post-commit, post-merge, post-checkout) to run "touch" on the .pro files. Ideally this would cause qmake to re-run after any change to the current git state.

    The problem is that git hooks aren't propagated by a clone, so it would be necessary to do something clever to make sure they get activated in every newly-cloned repo. Also, it's not obvious that this is the intended use for these hooks (or else they'd have a state-changed hook).



  • Let me ask a slightly different, but related question.

    If you include(something.pri) in a pro file, then any changes to something.pri are detected by qtcreator and cause it to re-run qmake. Is include() the only qmake function that has this effect, or are there others? Is there a comprehensive list somewhere?



  • I found a better solution:

    DEFINES += VERSION=$(shell git describe)

    This makes the actual "git describe" command be run by the Makefile instead of by qmake, skipping the need to re-run qmake.

    I am still interested in answers to the above question about how qtcreator decides qmake needs to be rerun, though.



  • Hi, qmake will be re-run when your .pro file changed.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.