February 21, 2011

Algirdasss Algirdasss
Lab Rat
46 posts

QMake. Legendary scope switch CONFIG(debug, debug|release)

 

Hy,

I and many other developers came to this point, when project debug and release versions must have some different config. In QMake docs everything seems very easy … just use “debug { … }” or “release { … }” and you have what you want, but that that’s not so easy if one is using QtCreator.

For half of day I was searching for normal explanation in the internet what a heck these parameters mean in the config function: “CONFIG (debug, debug|release)” or “CONFIG (release, debug|release)”. There is some info in QMake docs but it does not make much sense for me. What exactly the second parameters does??

1 reply

February 22, 2011

Franzk Franzk
Lab Rat
837 posts

Here’s a little test .pro:

  1. CONFIG(debug) {
  2.     message(debug)
  3. }
  4. CONFIG(release) {
  5.     message(release)
  6. }
  7. CONFIG(debug, debug|release) {
  8.     message("debug, debug|release")
  9. }
  10. CONFIG(release, debug|release) {
  11.     message("release, debug|release")
  12. }

With the outputs:

  1. $ qmake
  2. Project MESSAGE: debug
  3. Project MESSAGE: release
  4. Project MESSAGE: debug, debug|release
  5.  
  6. $ qmake CONFIG-=release CONFIG+=debug
  7. Project MESSAGE: debug
  8. Project MESSAGE: debug, debug|release
  9.  
  10. $ qmake CONFIG-=release CONFIG-=debug
  11.  
  12. $ qmake CONFIG+=release CONFIG-=debug
  13. Project MESSAGE: release
  14. Project MESSAGE: release, debug|release

The second parameter seems to be which configuration options to check for. If I change the last check into
  1. CONFIG(release, debug|unrelease) {
  2.     message("release, debug|release")
  3. }

  1. $ qmake CONFIG+= release CONFIG-=debug
  2. Project MESSAGE: release

If I change the check into

  1. CONFIG(release, release) {
  2.     message("release, debug|release")
  3. }

I get

  1. $ qmake CONFIG+=release CONFIG+=debug
  2. Project MESSAGE: debug
  3. Project MESSAGE: release
  4. Project MESSAGE: debug, debug|release
  5. Project MESSAGE: release, debug|release

Besides specifying the items to check for, some seem to take precedence. I’m not all too sure how this is determined. Anyway, I hope this at least clarifies something.

 Signature 

“Horse sense is the thing a horse has which keeps it from betting on people.”—W.C. Fields

http://www.catb.org/~esr/faqs/smart-questions.html

 
  ‹‹ QtCreator -- Making Qt Creator find other sources when using Signals/Slots, and deploying for Win..      Qt Creator 2.0.1 svn and proxy ››

You must log in to post a reply. Not a member yet? Register here!