QMake: how areas work?

For some strange reason, I can't get QMake to work. Here is the code in the 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 on 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 

Please note that I tried to clean my project and also manually delete make files. Now, why does he accept definitions from both areas? In addition, I do not see messages, where should they be?

+4
source share
2 answers

I had the same problem. To solve this problem, I used the CONFIG function instead of regions. This section of your .pro file will look like this:

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

Tried this in a simple HelloWorld project, and everything seemed to work just fine.

+2
source

There is another debug_and_release configuration option that allows you to create both modes at the same time. In this case, it fixes that both of your scopes start.

Try adding CONFIG=debug to your initial qmake command; it should override any automatic defaults and limit debugging mode.

As a debugging measure, you can also try to output the entire contents of CONFIG via message($$CONFIG) to your .pro file. Messages are printed when qmake starts, not when compiling make files.

+1
source

All Articles