Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
qtws26_logo

The Qt Event of the Year: Qt World Summit 2026

Save Your Spot >
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. #ifdef'ing between Desktop and Device builds
Qt 6.12 LTS is out! See what's new in the release blog

#ifdef'ing between Desktop and Device builds

Scheduled Pinned Locked Moved Mobile and Embedded
3 Posts 2 Posters 4.1k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • ? Offline
    ? Offline
    A Former User
    wrote on last edited by
    #1

    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
    1 Reply Last reply
    0
    • ? Offline
      ? Offline
      A Former User
      wrote on last edited by
      #2

      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
      @

      1 Reply Last reply
      0
      • ? Offline
        ? Offline
        A Former User
        wrote on last edited by
        #3

        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
        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt
        • Unsolved