Is it possible to add a dependency to your Makefil

2019-06-26 03:18发布

问题:

Currently, I have a file which contains some version tagging information which is used by the .pro file and parsed by qmake, but the problem is that when that file changes qmake is not re-run.

Is it possible to add something to the .pro file so that qmake will treat this file as a dependency for the Makefile?

回答1:

Sometheing like this should work:

depend_on_file.target = depend_on_file
depend_on_file.depends = path_to_your_txt_file
depend_on_file.CONFIG += recursive
QMAKE_EXTRA_TARGETS += depend_on_file
PRE_TARGETDEPS += depend_on_file

Rebuild will be triggered if file path_to_your_txt_file changes but keep in mind that if your qmake script that parses the file changes DEFINES variable then you out of luck. Defines are not listed in dependencies, you see. If defines are changed you have to do full rebuild by hand.