October 26, 2010

dusktreader dusktreader
Lab Rat
59 posts

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?

 Signature 

“Machines take me by surprise with great frequency.” —Alan Mathison Turing

4 replies

October 27, 2010

Franzk Franzk
Lab Rat
830 posts

Haven’t tested, but maybe adding paths to DEPENDPATH could help. For example:

  1. DEPENDPATH += . src include

 Signature 

“Horse sense is the thing a horse has which keeps it from betting on people.”—W.C. Fields

http://www.catb.org/~esr/faqs/smart-questions.html

October 27, 2010

Deleted Member # 4a2 Deleted Member # 4a2
Ant Farmer
1481 posts

by default it will rebuild when you modify any header.. can you post your .pro file here

October 27, 2010

kalle kalle
Lab Rat
42 posts

QMake will only observe dependencies in files listed in .pro files, or files in DEPENDPATH and INCLUDEPATH.

October 28, 2010

dusktreader dusktreader
Lab Rat
59 posts

Here is my .pro file:

  1. TARGET = outlierdetecttest
  2. TEMPLATE = app
  3.  
  4. INCLUDEPATH += \
  5.     ../../../tools \
  6.     ../..
  7.  
  8. SOURCES += \
  9.     main.cpp \
  10.     ../../../tools/tools.cpp
  11.  
  12. HEADERS += \
  13.     ../../../tools/tools.h \
  14.     ../../outlier.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 |- outlier.h |- 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?

 Signature 

“Machines take me by surprise with great frequency.” —Alan Mathison Turing

 
  ‹‹ QMake’s destiny      Creator 2.1 beta 1 mingw32-make.exe ››

You must log in to post a reply. Not a member yet? Register here!