QtCreator: kit-specific precompiler macro definitions



  • I am using QtCreator 3.1.1 to build a cross-platform project, and so I arranged to have different compilation kits for targeting my desktop PC and my BeagleBoneBlack (BBB).

    Now I would like to define some macro in qmake project file (.pro) which are specific only for a given kit.

    In other words I would like do in my .pro file something like:

    @ if(kit == BBB)
    DEFINES += MY_BBB_MACRO
    elseif(kit == Desktop)
    DEFINES += MY_DESKTOP_MACRO
    else
    DEFINES += OTHER_MACRO@

    Is is possible? How can I do that?


  • Moderators



  • Thanks koahnig... Following your hints I finally came up in adding a CONFIG directive to my platform, as in the following picture (in the provided example I added CONFIG+=BBB, on other kits I've added CONFIG+=AM335x and CONFIG+=Desktop):

    !http://it.tinypic.com/r/mh8qyg/8()!

    and then, using the built-in test functions, I slightly modified my .pro file to include the requested platform-specific defines:

    !http://it.tinypic.com/r/2qwcwhh/8()!

    and it works! Now in my code I can use #ifdef PLATFORM_BBB or #ifdef PLATFORM_AM335X or #ifdef PLATFORM_DESKTOP to differentiate the program behaviour on different platforms.

    Thanks!


  • Moderators

    You are welcome. Glad to see that my comment helped ;-)
    qmake is quite powerful, but the documentation and tutorials could benefit from a tune-up.


Log in to reply
 

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