Re: [SailfishDevel] Check for OS in .PRO file
I use similar approach, but I do qmake CONFIG+=sailfish and then I can check for it in the .pro file like this: sailfish { DEFINES += Q_OS_SAILFISH ... } Looks shorter and cleaner to me :-) On 03.01.2014 12:21, Timur Kristóf wrote: Hi, What Thomas said makes sense, I just want to add one more little thing. You can, in the .spec file, add stuff to qmake, like this define. This would make the necessary code shorter and as a bonus, it gives you something you can even ifdef in C++. # spec file qmake DEFINES+=IS_SAILFISH_OS # pro file contains(DEFINES, IS_SAILFISH_OS) { ... } // C++ file #if defined(IS_SAILFISH_OS) ... #endif Cheers, Timur Timur On Thu, Jan 2, 2014 at 8:44 PM, Thomas Perl mailto:th.p...@gmail.com>> wrote: Hi, On 02 Jan 2014, at 20:25, Sven Putze mailto:sailfish...@hardcodes.de>> wrote: > There are ways to check for the OS in QtCreator .PRO files, e.g. like > > unix:symbian{ # do stuff} > unix:maemo5{ # do stuff} > macx{ # do stuff} > win32{ # do stuff} > > Is there a way to check (or control to be more precise) that some directives are only used when compiling on the MerSDL VM? > Just checking for the presence of "sailfishapp" does not work, because that is defined for any OS. In general, it might just be easier (and more maintainable) to have a per-platform .pro file for your project and not litter your .pro file with lots of conditionals (been there, done that - it will become hard to read, understand and maintain as the number of platforms grows). If there’s a lot of common things that you need in each file, put that in a .pri file and include it in each platform-specific .pro file. Then, in the sailfish .spec, you can call qmake on the sailfish-specific project file, in the Maemo 5 debian/rules script, you call qmake on the maemo5 .pro file, etc… With that said, you can use packagesExist[1] to do sailfish-specific things if you are convinced that a single .pro file really is the way to go: packagesExist(sailfishapp) { .. do stuff .. } Alternatively, set an environment variable in the qmake call in the .spec file and check for that variable in the .pro file: # In the .spec file: IS_SAILFISH_OS=1 qmake # In the .pro file: IS_SAILFISH_OS = $$(IS_SAILFISH_OS) contains(IS_SAILFISH_OS, 1) { .. do stuff .. } HTH :) Thomas [1] http://qt-project.org/doc/qt-4.8/qmake-function-reference.html#packagesexist-packages -- With best regards, Oleksii Serdiuk smime.p7s Description: S/MIME Cryptographic Signature ___ SailfishOS.org Devel mailing list
Re: [SailfishDevel] Check for OS in .PRO file
Thanks, Thomas' hint of avoiding the conditionals convinced me somehow :-) BR. Sven On 04.01.2014, at 12:15, David Greaves wrote: > Just for the record this will fail to build on the Community OBS or even in a > Mer Platform SDK using a SailfishOS target. > > Thomas and Timur's suggestions would work. > > David > > On 04/01/14 10:42, Putze Sven wrote: >> Hi, >> >> I should read my mails more often 8) Just figured out >> >> win32|macx{ >>SDKHOSTNAME=unknown >> } >> linux-g++{ >>SDKHOSTNAME=$$system(hostname) >> } >> contains(SDKHOSTNAME , "SailfishSDK"){ >>message("Heureka! Running on the MerSDK VM") >> } >> else{ >>message("running somewhere else") >> } >> >> >> But I will also think about what you guys wrote, thank you! >> >> BR. >> Sven >> >> On 02.01.2014, at 20:25, Sven Putze wrote: >> >>> Hi there, >>> >>> first of all a happy new year to everyone! I had some time offline this >>> morning, so here comes a bunch of emails... >>> >>> >>> There are ways to check for the OS in QtCreator .PRO files, e.g. like >>> >>> unix:symbian{ # do stuff} >>> unix:maemo5{ # do stuff} >>> macx{ # do stuff} >>> win32{ # do stuff} >>> >>> Is there a way to check (or control to be more precise) that some >>> directives are only used when compiling on the MerSDL VM? >>> Just checking for the presence of "sailfishapp" does not work, because that >>> is defined for any OS. >>> >>> BR. >>> Sven >>> ___ >>> SailfishOS.org Devel mailing list >> >> ___ >> SailfishOS.org Devel mailing list >> > ___ SailfishOS.org Devel mailing list
Re: [SailfishDevel] Check for OS in .PRO file
Just for the record this will fail to build on the Community OBS or even in a Mer Platform SDK using a SailfishOS target. Thomas and Timur's suggestions would work. David On 04/01/14 10:42, Putze Sven wrote: > Hi, > > I should read my mails more often 8) Just figured out > > win32|macx{ > SDKHOSTNAME=unknown > } > linux-g++{ > SDKHOSTNAME=$$system(hostname) > } > contains(SDKHOSTNAME , "SailfishSDK"){ > message("Heureka! Running on the MerSDK VM") > } > else{ > message("running somewhere else") > } > > > But I will also think about what you guys wrote, thank you! > > BR. > Sven > > On 02.01.2014, at 20:25, Sven Putze wrote: > >> Hi there, >> >> first of all a happy new year to everyone! I had some time offline this >> morning, so here comes a bunch of emails... >> >> >> There are ways to check for the OS in QtCreator .PRO files, e.g. like >> >> unix:symbian{ # do stuff} >> unix:maemo5{ # do stuff} >> macx{ # do stuff} >> win32{ # do stuff} >> >> Is there a way to check (or control to be more precise) that some directives >> are only used when compiling on the MerSDL VM? >> Just checking for the presence of "sailfishapp" does not work, because that >> is defined for any OS. >> >> BR. >> Sven >> ___ >> SailfishOS.org Devel mailing list > > ___ > SailfishOS.org Devel mailing list > ___ SailfishOS.org Devel mailing list
Re: [SailfishDevel] Check for OS in .PRO file
Hi, I should read my mails more often 8) Just figured out win32|macx{ SDKHOSTNAME=unknown } linux-g++{ SDKHOSTNAME=$$system(hostname) } contains(SDKHOSTNAME , "SailfishSDK"){ message("Heureka! Running on the MerSDK VM") } else{ message("running somewhere else") } But I will also think about what you guys wrote, thank you! BR. Sven On 02.01.2014, at 20:25, Sven Putze wrote: > Hi there, > > first of all a happy new year to everyone! I had some time offline this > morning, so here comes a bunch of emails... > > > There are ways to check for the OS in QtCreator .PRO files, e.g. like > > unix:symbian{ # do stuff} > unix:maemo5{ # do stuff} > macx{ # do stuff} > win32{ # do stuff} > > Is there a way to check (or control to be more precise) that some directives > are only used when compiling on the MerSDL VM? > Just checking for the presence of "sailfishapp" does not work, because that > is defined for any OS. > > BR. > Sven > ___ > SailfishOS.org Devel mailing list ___ SailfishOS.org Devel mailing list
Re: [SailfishDevel] Check for OS in .PRO file
Hi, What Thomas said makes sense, I just want to add one more little thing. You can, in the .spec file, add stuff to qmake, like this define. This would make the necessary code shorter and as a bonus, it gives you something you can even ifdef in C++. # spec file qmake DEFINES+=IS_SAILFISH_OS # pro file contains(DEFINES, IS_SAILFISH_OS) { ... } // C++ file #if defined(IS_SAILFISH_OS) ... #endif Cheers, Timur Timur On Thu, Jan 2, 2014 at 8:44 PM, Thomas Perl wrote: > Hi, > > On 02 Jan 2014, at 20:25, Sven Putze wrote: > > There are ways to check for the OS in QtCreator .PRO files, e.g. like > > > > unix:symbian{ # do stuff} > > unix:maemo5{ # do stuff} > > macx{ # do stuff} > > win32{ # do stuff} > > > > Is there a way to check (or control to be more precise) that some > directives are only used when compiling on the MerSDL VM? > > Just checking for the presence of "sailfishapp" does not work, because > that is defined for any OS. > > > In general, it might just be easier (and more maintainable) to have a > per-platform .pro file for your project and not litter your .pro file with > lots of conditionals (been there, done that - it will become hard to read, > understand and maintain as the number of platforms grows). If there’s a lot > of common things that you need in each file, put that in a .pri file and > include it in each platform-specific .pro file. Then, in the sailfish > .spec, you can call qmake on the sailfish-specific project file, in the > Maemo 5 debian/rules script, you call qmake on the maemo5 .pro file, etc… > > With that said, you can use packagesExist[1] to do sailfish-specific > things if you are convinced that a single .pro file really is the way to go: > > packagesExist(sailfishapp) { .. do stuff .. } > > Alternatively, set an environment variable in the qmake call in the .spec > file and check for that variable in the .pro file: > > # In the .spec file: > IS_SAILFISH_OS=1 qmake > > # In the .pro file: > IS_SAILFISH_OS = $$(IS_SAILFISH_OS) > contains(IS_SAILFISH_OS, 1) { > .. do stuff .. > } > > > HTH :) > Thomas > > [1] > http://qt-project.org/doc/qt-4.8/qmake-function-reference.html#packagesexist-packages > ___ > SailfishOS.org Devel mailing list > ___ SailfishOS.org Devel mailing list
Re: [SailfishDevel] Check for OS in .PRO file
Hi, On 02 Jan 2014, at 20:25, Sven Putze wrote: > There are ways to check for the OS in QtCreator .PRO files, e.g. like > > unix:symbian{ # do stuff} > unix:maemo5{ # do stuff} > macx{ # do stuff} > win32{ # do stuff} > > Is there a way to check (or control to be more precise) that some directives > are only used when compiling on the MerSDL VM? > Just checking for the presence of "sailfishapp" does not work, because that > is defined for any OS. In general, it might just be easier (and more maintainable) to have a per-platform .pro file for your project and not litter your .pro file with lots of conditionals (been there, done that - it will become hard to read, understand and maintain as the number of platforms grows). If there’s a lot of common things that you need in each file, put that in a .pri file and include it in each platform-specific .pro file. Then, in the sailfish .spec, you can call qmake on the sailfish-specific project file, in the Maemo 5 debian/rules script, you call qmake on the maemo5 .pro file, etc… With that said, you can use packagesExist[1] to do sailfish-specific things if you are convinced that a single .pro file really is the way to go: packagesExist(sailfishapp) { .. do stuff .. } Alternatively, set an environment variable in the qmake call in the .spec file and check for that variable in the .pro file: # In the .spec file: IS_SAILFISH_OS=1 qmake # In the .pro file: IS_SAILFISH_OS = $$(IS_SAILFISH_OS) contains(IS_SAILFISH_OS, 1) { .. do stuff .. } HTH :) Thomas [1] http://qt-project.org/doc/qt-4.8/qmake-function-reference.html#packagesexist-packages ___ SailfishOS.org Devel mailing list
[SailfishDevel] Check for OS in .PRO file
Hi there, first of all a happy new year to everyone! I had some time offline this morning, so here comes a bunch of emails... There are ways to check for the OS in QtCreator .PRO files, e.g. like unix:symbian{ # do stuff} unix:maemo5{ # do stuff} macx{ # do stuff} win32{ # do stuff} Is there a way to check (or control to be more precise) that some directives are only used when compiling on the MerSDL VM? Just checking for the presence of "sailfishapp" does not work, because that is defined for any OS. BR. Sven ___ SailfishOS.org Devel mailing list