PDA

View Full Version : QMake Passing variables to subprojects



Ermoghen
15th April 2015, 15:33
Hello, everyone!

I have the following situation:

ParentProject_1.pro
TEMPLATE = subdirs
INCLUDE_SUBSUBPROJECT = 1
SUBDIRS += Child.pro

ParentProject_2.pro
TEMPLATE = subdirs
INCLUDE_SUBSUBPROJECT = 0
SUBDIRS += Child.pro

Child.pro
TEMPLATE = subdirs
contains(INCLUDE_SUBSUBPROJECT, 1){
SUBDIRS += Subsubproject.pro
}

This does not work as is because the INCLUDE_SUBSUBPROJECT value is not transfered from parent projects to Child.pro, so Subsubproject.pro will never be included. One way seems to be using command line params for qmake, but it becomes problematic with more complex scenarios and I would really like to avoid it. Is there another way?

anda_skoa
15th April 2015, 16:50
I would approach this with a Child.pri file that contains the common parts and two Child .pro files

Child.pro


include(Child.pri)


ChildWithSubSub.pro


include(Child.pri)

# SubSub stuff


ParentProject1.pro


SUBDIRS +=ChildWithSubSub.pro


ParentProject2.pro


SUBDIRS +=Child.pro


Cheers,
_

Ermoghen
16th April 2015, 07:08
Thank you for your answer. Unfortunately, I have a more complex situation, in the sense that Child.pro has multiple subsubprojects that are combined differently when called from diffrent parents. Of course, your aproach remains valid and I will most probably use it. However, I was hoping to be able to have an unique Child.pro, becuase it seemed more ellegant to me.

anda_skoa
16th April 2015, 10:05
Hmm.
Maybe try adding to the CONFIG variable?

Cheers,
_

Ermoghen
22nd April 2015, 14:04
I changed the approach and used something like you said in the first reply. Thank you!