Hi,

I use Qt 4.7.3 on Linux, and I am facing weird qmake behavior. I have tried to narrow the problem down to the following minimal example:

I have a directory, qmake_example, which contains two files:

Qt Code:
  1. $ cat qmake_example.pro
  2. CONFIG += debug_and_release
  3.  
  4. release: DESTDIR = release
  5. debug: DESTDIR = debug
  6.  
  7. SOURCES += main.cpp
  8.  
  9. $ cat main.cpp
  10. int main()
  11. {
  12. return 0;
  13. }
To copy to clipboard, switch view to plain text mode 

As you can see:
1. I want to be able to build the project in debug and/or release mode.
2. I want to keep the generated binaries in build subdirectories separate from the source directory.

First I run qmake, which generates the expected Makefiles and build subdirectories:

Qt Code:
  1. $ ls
  2. main.cpp qmake_example.pro
  3. $ qmake
  4. $ ls
  5. debug Makefile Makefile.Release release
  6. main.cpp Makefile.Debug qmake_example.pro
To copy to clipboard, switch view to plain text mode 

Then I run make to generate both debug and release builds:

Qt Code:
  1. $ make debug release # I also tried the equivalent 'make all'
  2. <g++'s output lines, no warnings, no errors>
To copy to clipboard, switch view to plain text mode 

But then, surprise: the binary is generated only for debug:

Qt Code:
  1. $ ls debug/
  2. main.o qmake_example
  3. $ ls release/
  4. main.o
To copy to clipboard, switch view to plain text mode 

The problem is in Makefile.Release, which contains (among other lines):

Qt Code:
  1. # Makefile for building: debug/qmake_example
  2. [more lines]
  3. DESTDIR = debug/
  4. TARGET = debug/qmake_example
  5. [more lines]
  6. @$(CHK_DIR_EXISTS) debug/ || $(MKDIR) debug/
  7. [more lines]
To copy to clipboard, switch view to plain text mode 

What am I doing wrong? How should I write my .pro file / invke qmake in order to have Makefile.Release refer to directory release instead of debug?