#ifdef'ing between Desktop and Device builds



  • Hi, was wondering what's The way to do conditional compilation between Desktop and Device environments? I know there is Q_OS_LINUX but since I am developing on Ubuntu for Harmattan, I assume this would be defined for both :)

    Perhaps it's possible to #define a custom flag in the .pro file using unix: { } and the makespec somehow, anyone done this?

    • M


  • You will find a list of platform specific defines "here":http://doc.qt.nokia.com/latest/qtglobal.html#Q_OS_AIX.

    @
    // .pro
    contains(MEEGO_EDITION,harmattan) {
    DEFINES += BUILD_DEVICE
    } else {
    DEFINES += BUILD_DESKTOP
    }

    // .cpp
    #if defined(BUILD_DEVICE)
    ...
    #elif defined(BUILD_DESKTOP)
    ...
    #else
    #error Unsupported platform.
    #endif
    @



  • Oh cheers. After playing around with this a while, I decided to try to go for something more generic:

    @win32|linux-g++|linux-g++-64 {
    DEFINES += BUILD_DESKTOP
    message(Desktop build)
    } else {
    DEFINES += BUILD_DEVICE
    message(Device build)
    }@

    • M

Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.