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?
I found another solution.
First, add additional arguments in Projects using
CONFIG+=Variable
name for kit.And in .pro file, write some code like below.
If you look at the general message tab, you can see that the setting works well.
I obtained some help on Qt forum (take a look here) about this problem...
Anyway the solution consists in using qmake built-in test functions.
Basically I've added some
CONFIG
directive in QtCreator's project management: in the following screenshot you can see for example you can see that I've addedCONFIG+=BBB
in the project configuration for BBB kit; in the same way I've addedCONFIG+=AM335x
andCONFIG+=Desktop
to AM335x and Desktop kits, respectively...Then, in my
.pro
file I've added something like:and now in my source code I can use something like
#ifdef PLATFORM_BBB
,#ifdef PLATFORM_AM335X
and#ifdef PLATFORM_DESKTOP
for differentiating the program behavior depending on compilation kit.