force build to be dependent on changes in header files in QtCreator/QMake
It seems that by default the build functionality of QtCreator is only dependent on changes in the source files. So, for example, if I change a file in the SOURCES variable, initiating a “run” or “build” request from QtCreator will rebuild all objects dependent on those source files. However, if I change a file in the HEADERS list and initiate a “build” or “run” request, no objects will be rebuilt.
How do I make the current build of my application dependent on a header file so that if a header changes the dependent objects are rebuilt?
I know how to do this with standard make (i.e. add dependency to a .h file). How can I specify this sort of thing in a QMake .pro file?
Here is my .pro file:
- TARGET = outlierdetecttest
- TEMPLATE = app
- INCLUDEPATH += \
- ../../../tools \
- SOURCES += \
- main.cpp \
- HEADERS += \
- ../../../tools/tools.h \
This project simply tests the functionality of a custom header. The header has templated source code, so there is no accompanying .cpp file. The layout of the projects is as follows
~/analysis/ # This is the main source folder for my large project
|- other source and header files
~/analysis/sandbox/outlierdetecttest/ # This is the folder where the project for testing the outlier detection header lies |- main.cpp |- outlierdetecttest.pro
The tools.h files are only used for debugging, and really aren’t necessary.—
Now, suppose I have already built the project. I run it and decide to change something in the header. After I edit the header and hit the build button (or ctrl-b ), nothing happens. If, however, I edit the main.cpp source file and request a rebuild, then the executable is rebuilt.
I do not want to make the main source folder ( ~/analysis) part of the dependency path. I only want to make the outlierdetecttest build depend on changes in the header file. How can I do this?