Search code examples
qtqmake

QMake: how do scopes work?


For some weird reason I can't get scopes in QMake to work. Here's some code in my project file:

debug {
    QMAKE_CXXFLAGS_DEBUG += -g3 -O0
    message ("Some debug output")
}

release {
    DEFINES += QT_NO_DEBUG
    DEFINES += QT_NO_DEBUG_OUTPUT
    message ("No debug output")
}

But when I compile it in debug mode, here's the gcc command line I get:

g++ -c -g -g3 -O0 -frtti -fexceptions -mthreads -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT -DLIBPROVERIM_LIBRARY -DQT_NO_DEBUG -DQT_NO_DEBUG_OUTPUT -DWINDOWS -DQT_DLL -DQT_SQL_LIB -DQT_XML_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -DQT_THREAD_SUPPORT -I"c:\Qt\2010.05\qt\include\QtCore" -I"c:\Qt\2010.05\qt\include\QtNetwork" -I"c:\Qt\2010.05\qt\include\QtGui" -I"c:\Qt\2010.05\qt\include\QtXml" -I"c:\Qt\2010.05\qt\include\QtSql" -I"c:\Qt\2010.05\qt\include" -I"c:\Qt\2010.05\qt\include\ActiveQt" -I"debug" -I"..\proverim" -I"." -I"c:\Qt\2010.05\qt\mkspecs\win32-g++" -o debug\PForm.o ..\proverim\PForm.cc

Note that I tried cleaning my project, as well as manually removing makefiles. Now why does it take defines from both scopes? Also, I don't see any messages, where are they supposed to be?


Solution

  • I had the same problem. To solve it I used the CONFIG "function" instead of the scopes. That section of your .pro file would be:

    CONFIG(debug, debug|release) {
    QMAKE_CXXFLAGS_DEBUG += -g3 -O0
    message("DEBUG!")
    } else {
    DEFINES += QT_NO_DEBUG
    DEFINES += QT_NO_DEBUG_OUTPUT
    message("RELEASE!")
    }
    

    Tried it in a simple "HelloWorld" project and everything seemed to work fine.