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:
$ cat qmake_example.pro
CONFIG += debug_and_release
release: DESTDIR = release
debug: DESTDIR = debug
SOURCES += main.cpp
$ cat main.cpp
int main()
{
return 0;
}
$ cat qmake_example.pro
CONFIG += debug_and_release
release: DESTDIR = release
debug: DESTDIR = debug
SOURCES += main.cpp
$ cat main.cpp
int main()
{
return 0;
}
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:
$ ls
main.cpp qmake_example.pro
$ qmake
$ ls
debug Makefile Makefile.Release release
main.cpp Makefile.Debug qmake_example.pro
$ ls
main.cpp qmake_example.pro
$ qmake
$ ls
debug Makefile Makefile.Release release
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:
$ make debug release # I also tried the equivalent 'make all'
<g++'s output lines, no warnings, no errors>
$ make debug release # I also tried the equivalent 'make all'
<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:
$ ls debug/
main.o qmake_example
$ ls release/
main.o
$ ls debug/
main.o qmake_example
$ ls release/
main.o
To copy to clipboard, switch view to plain text mode
The problem is in Makefile.Release, which contains (among other lines):
# Makefile for building: debug/qmake_example
[more lines]
DESTDIR = debug/
TARGET = debug/qmake_example
[more lines]
@$(CHK_DIR_EXISTS) debug/ || $(MKDIR) debug/
[more lines]
# Makefile for building: debug/qmake_example
[more lines]
DESTDIR = debug/
TARGET = debug/qmake_example
[more lines]
@$(CHK_DIR_EXISTS) debug/ || $(MKDIR) debug/
[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?
Bookmarks