Results 1 to 5 of 5

Thread: Pre-processor-defines depending on makefile-targets ?

  1. #1
    Join Date
    Sep 2008
    Posts
    23
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Pre-processor-defines depending on makefile-targets ?

    Hi,

    I'm searching for a possibility to create pre-processor-defines depending on the called makefile target.
    I'm currently using the usual solution for conditional compiling of debug code parts:
    Qt Code:
    1. #ifdef DEBUG
    2. ...debug-code
    3. #endif
    To copy to clipboard, switch view to plain text mode 
    At the moment, I set DEBUG in a separate header-file, which I have to include in all souces that contain such debug-sequences.
    My idea/intention is to make this separate header-file obsolete. DEBUG should be set when I compile the software with "make debug" (only).

    It's a qmake-project and I use CONFIG += debug_and_relase.

    I know the DEFINES option, but don't know how to make it depending on the called make target. Does anyone know how to do that ?

    Frank
    Last edited by Comer352l; 11th March 2009 at 18:59.

  2. #2
    Join Date
    Jul 2006
    Location
    Catalunya - Spain
    Posts
    117
    Thanks
    16
    Thanked 8 Times in 8 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Pre-processor-defines depending on makefile-targets ?

    Have you tried ?

    Qt Code:
    1. debug:DEFINES += __MY_DEBUG_DEFINE__
    2. release:DEFINES += __MY_RELEASE_DEFINE__
    To copy to clipboard, switch view to plain text mode 

  3. #3
    Join Date
    Sep 2008
    Posts
    23
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Pre-processor-defines depending on makefile-targets ?

    Thanks for your answer ! Yes, I already tried that but it doesn't work :
    Becasue of CONFIG += debug_and_release, always both (__MY_DEBUG_DEFINE__ and __MY_RELEASE_DEFINE__) will be defined. It doesn't matter which makefile-target I call...

  4. #4
    Join Date
    Sep 2008
    Posts
    23
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Pre-processor-defines depending on makefile-targets ?

    I finally solved it:

    Qt Code:
    1. CONFIG(debug, debug|release) {
    2. DEFINES = __MY_DEBUG_DEFINE__
    3. } else {
    4. DEFINES = __MY_RELEASE_DEFINE__
    5. }
    To copy to clipboard, switch view to plain text mode 

    I still don't understand CONFIG(...) completely, documentation is really incomplete for stuff like this...

  5. #5
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,017 Times in 4,793 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Pre-processor-defines depending on makefile-targets ?

    Have you seen the article in our wiki regarding [wiki]Undocumented qmake[/wiki] features?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. not able to change Makefile
    By shamik in forum Qt Programming
    Replies: 1
    Last Post: 9th June 2007, 12:00

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
  •  
Qt is a trademark of The Qt Company.