Results 1 to 7 of 7

Thread: qmake generates bogus Makefiles

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2011
    Posts
    7
    Qt products
    Qt4
    Platforms
    Windows

    Default qmake generates bogus Makefiles

    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?

  2. #2
    Join Date
    Dec 2009
    Location
    New Orleans, Louisiana
    Posts
    791
    Thanks
    13
    Thanked 153 Times in 150 Posts
    Qt products
    Qt5
    Platforms
    MacOS X

    Default Re: qmake generates bogus Makefiles

    Here's what I use in my qmake pro files and works for me:
    Qt Code:
    1. CONFIG(debug, debug|release) {
    2. DESTDIR = build/debug
    3. } else {
    4. DESTDIR = build/release
    5. }
    To copy to clipboard, switch view to plain text mode 
    I write the best type of code possible, code that I want to write, not code that someone tells me to write!

Similar Threads

  1. Enabling MakeFiles Through .pro files of Qt
    By zgulser in forum Qt Programming
    Replies: 2
    Last Post: 14th May 2012, 23:47
  2. Replies: 12
    Last Post: 7th July 2009, 17:32
  3. Generated Makefiles clean-up
    By tora in forum Qt Programming
    Replies: 3
    Last Post: 4th June 2009, 11:45
  4. qmake does not create visual studio makefiles
    By AlphaWolf in forum Installation and Deployment
    Replies: 2
    Last Post: 6th March 2009, 17:02
  5. Replies: 1
    Last Post: 11th January 2006, 14:15

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.