Important: Please read the Qt Code of Conduct -

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)
    elseif(kit == Desktop)

    Is is possible? How can I do that?

  • 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):


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


    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.


  • 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