11

Issue

I am working on a multi-executable QT project using qmake in conjunction with QT Creator. Each executable has its' own .pro file, all of which are included in an over-arching .pro file (template=subdirs). Each individual .pro file also includes a common .pri file which sets DESTDIR so that all the executables end up in the same place. This DESTDIR is dependent on whether it is being compiled as debug or release. This has worked wonderfully until we added a collection of executables via another subdir .pro beneath the over-arching one. The overall setup looks something like this:

  • All.pro
  • | - Project1.pro
  • | - Project2.pro
  • | - Subdirs.pro
  • | -- | - Project3.pro
  • | -- | - Project4.pro

If you have a freshly checked out copy, you can run qmake and all will work, until you switch from debug to release, or vice-versa. When you do, Project1.pro and Project2.pro update just fine and put their executables in the right directory, but Project3.pro and Project4.pro use the old directory.


Attempts

If I manually remove all the affected makefiles, qmake will generate new ones. I suppose I could write some sort of a pre-compile command to remove all makefiles every time, but that seems like the wrong way to do things, let alone the amount of time I would have to spend making sure it worked on all our platforms.

I have tried this in QT 4.6.4 through 4.8.1

When I use QT Creator, I switch between Debug and Release modes via differing build configurations which mimics what I do on the command lie (ie adding or removing CONFIG+=debug)


Questions

  • What is preventing qmake from updating the makefiles?
  • If it is just a bug in qmake, what is the best workaround?

Any and all help is greatly appreciated.

Tsubashi
  • 730
  • 11
  • 26
  • Can you add more information about how you are switching between release and debug? Is it via QtCreator or command line? If command line, what commands in particular? Do you run any custom targets to switch? – Caleb Huitt - cjhuitt Oct 02 '12 at 15:47
  • I have updated the question to include that. – Tsubashi Oct 03 '12 at 16:52

2 Answers2

10

Even though the QMake documentation indicates it is only for Project Mode (creating .pro files), try adding the -r option to qmake to force it to recurse through the directories.

This is what we have used on our many level deep SUBDIR projects in the past.

jwernerny
  • 6,978
  • 2
  • 31
  • 32
  • That does not seem to work for me. Admittedly it does generate new makefiles under new names (ie. makefile.Project3 instead of makefile.Subdirs.Project3) with the correct configuration, but they seem to be ignored. – Tsubashi Oct 03 '12 at 16:58
  • @cscott How about deleting existing makefiles using a `make distclean` before running qmake? – jwernerny Oct 04 '12 at 12:27
  • While that does work, I also need a solution I can put into the .pro file, since I cannot commit my .user file. Any ideas? – Tsubashi Oct 04 '12 at 16:50
  • I don't think there is anything other than what you have that can be added to the .pro file. In our projects, we have just made it an additional build step that needs to be done. – jwernerny Oct 09 '12 at 15:53
  • Thanks, for lack of a better option so have we. – Tsubashi Oct 15 '12 at 22:48
1

We had the same issue and worked around it by running "make qmake" from top level directory after switching between debug/release.

Denis
  • 11
  • 1