Qt exclude subdir project depending on the platform

Viewed 140

I have this situation in my app.pro:

TEMPLATE = subdirs

SUBDIRS += A\
           B\
           C

B.depends = A
C.depends = A

I would like to exclude project C from build depending on the platform. I've tried to do the following but that's not working (project C is always included):

TEMPLATE = subdirs

SUBDIRS += A\
           B

android {
SUBDIRS += C
C.depends = A
}

B.depends = A

Is it possible to do something like that? Thank you

1 Answers

Your approach to exclude subdir project C for non-Android platforms looks correct.

If you take a look into qmake and make log output you see C is not built. I suppose you got confused because Qt Creator still showed C in project tree for you even excluded.

You can add message("inside android scope") to print a log message when qmake processes android scope of the pro file.

android {
    message("inside android scope")
    SUBDIRS += C
    C.depends = A
}
Related