Qt/qmake Sailfish target detection

Hi folks,

I would like to compile one of my applications for Sailfish and Android from the same project.

Are there any Sailfish specific macros defined like Q_OS_ANDROID in any Qt headers?

Having #ifdef Q_OS_ANDROID … #else - here goes SFOS #endif is an option, but if we have a proper define I would prefer that.

Due to the different Qt versions I might need to add some target dependent section to the qmake pro file as well. Is there any way to do that?

Not really

While there isn’t anything readily defined, it’s not too difficult to make such target dependent sections and defines yourself. In the .spec file you can pass whatever assignments you want to qmake. And then in the pro file you can test for them. And finally, in your target dependent section you can add the DEFINEs you want. So, something like this should work:

In .spec:
%qmake5 MY_TARGET=Sailfish

in .pro:

equals(MY_TARGET, "Sailfish") {

And then finally you can use #ifdef TARGET_SAILFISH in your sources.


HI @vige !
Many thanks for the tip, it will solve my issue.
Have a great day!

1 Like