Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Conditional compiling depending on target
Forum Updated to NodeBB v4.3 + New Features

Conditional compiling depending on target

Scheduled Pinned Locked Moved Mobile and Embedded
6 Posts 5 Posters 9.3k 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.
  • F Offline
    F Offline
    f.vanalmetelevic.com
    wrote on last edited by
    #1

    I'm developing an application that has to run on my host computer (Ubuntu) - mainly for testing purposes - as well as on our target board (with IMX27 processor). Some things, mainly related to hardware, are specific to the target board and have to be excluded from the host version. I would like to do that with conditional compiling, but don't know what to use to detect the target system. Can I use Q_CC_GNU as an indication for the host target ? Can anyone help ?

    1 Reply Last reply
    0
    • G Offline
      G Offline
      goetz
      wrote on last edited by
      #2

      Have a look at the Q_OS_XXX or Q_WS_XXX macros in "qglobal.h":http://doc.qt.nokia.com/4.7/qtglobal.html.

      If that does not fit you needs, you can manually define a macro in qmake's .pro file which is exposed to your code, probably together with a CONFIG switch on the qmake command line.

      @
      OnUbuntu:DEFINES += ON_UBUNTU
      OnBoard:DEFINES += ON_BOARD
      @

      You then can test in your code with #ifdef/#ifndef.

      Call qmake like this:

      @

      on your ubuntu box:

      qmake "CONFIG += OnUbuntu"

      or when compiling for your board:

      qmake "CONFIG += OnBoard"
      @

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

      1 Reply Last reply
      0
      • F Offline
        F Offline
        f.vanalmetelevic.com
        wrote on last edited by
        #3

        Seems to work. Thanks !

        1 Reply Last reply
        0
        • T Offline
          T Offline
          thp4
          wrote on last edited by
          #4

          If you also want to only use some Qt modules depending on where you are building, you could do something like this in your .pro file (note that you can either use ":" for a single line or "{" and "}" for a block):

          @
          linux-g++ {
          QT += opengl
          }
          @

          This will only enable the OpenGL module if you are building on Linux. Or if you only want D-Bus on Maemo 5 (but not on Symbian), you could do something like this:

          @
          linux-g++-maemo5 {
          QT += dbus
          }
          @

          As already mentioned, for doing #ifdefs in the code, use Q_WS_MAEMO_5 for Qt on the N900 and Q_OS_SYMBIAN for Symbian.

          1 Reply Last reply
          0
          • X Offline
            X Offline
            xsacha
            wrote on last edited by
            #5

            I've simply been using the Q_OS.. defines. What else do you need to define in your HAL.h that you can't already do with Qt defines?

            Might be a bit of redundancy there!

            • Sacha
            1 Reply Last reply
            0
            • D Offline
              D Offline
              DenisKormalev
              wrote on last edited by
              #6

              tamhanna, I think such things should be made by compilation flags, not by header.

              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 Extensions
              • Unsolved