[QBS] Properties for multiple conditions
Jake Petroules
jake.petroules at petroules.com
Mon Dec 16 13:36:57 CET 2013
Hi Markus,
Properties items are indeed interpreted similarly to an if-else chain. To achieve the behaviour you are looking for, you may use the following:
cpp.defines: {
var defines = ["MY_DEFINE"];
if (qbs.targetOS.contains("linux"))
defines.push("LNX_DEFINE");
if (qbs.targetOS.contains("windows"))
defines.push("WIN_DEFINE");
if (qbs.buildVariant.contains("debug"))
defines.push("DBG_DEFINE");
return defines;
}
--
Jake Petroules
Chief Technology Officer
Petroules Corporation ยท www.petroules.com
Email: jake.petroules at petroules.com
On Dec 16, 2013, at 7:29 AM, Markus Biggel <sicus01 at googlemail.com> wrote:
> I want to set up a project with properties to set macros, now more than one property can be true, but this does not work. how can I realize this. for example:
>
> I want the macro LNX_DEFINE under linux, WIN_DEFINE under windows, DBG_DEFINE if the project is build as debug and MY_DEFINE which is always set. I tried the following:
>
> //--------------- part of qbs file --------------------------------
> Properties {
> condition: qbs.targetOS.contains("linux")
> cpp.defines: LNX_DEFINE
> }
>
> Properties {
> condition: qbs.targetOS.contains("windows")
> cpp.defines: WIN_DEFINE
> }
>
> Properties {
> condition: qbs.buildVariant.contains("debug")
> cpp.defines: DBG_DEFINE
> }
>
> Properties {
> condition: true
> cpp.defines: MY_DEFINE
> }
> //-----------------------------------------------
>
> If I build debug on linux, I expected to see LNX_DEFINE, DBG_DEFINE and MY_DEFINE set, release on windows WIN_DEFINE and MY_DEFINE and so on. But this is not the case, the first true condition is set, all conditions below are ignored. it looks like this is equivalent to
> if (targetOS.contains("linux") {}
> else if (targetOS.contains("windows")) {}
> else if (buildVariant.contains("debug") {}
>
> But I need something like:
> if (targetOS.contains("linux") {}
> if (targetOS.contains("windows")) {}
> if (buildVariant.contains("debug") {}
>
> or, at least, the buildVariant condition is treated seperately from targetOS (two ore more blocks of buildVariant or targetOS can be, of couse, if - else equivalents), like:
>
> if (targetOS.contains("linux") {}
> else if (targetOS.contains("windows") {}
> if (buildVariant.contains("debug") {}
>
> Is there a way to realize this?
> _______________________________________________
> QBS mailing list
> QBS at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/qbs
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/qbs/attachments/20131216/b970357e/attachment.html>
More information about the Qbs
mailing list