13
votes

Greetings,

I've got a .pro file that looks like:

TEMPLATE = subdirs
SUBDIRS = foo bar

I want to set a variable, or define, or something in my subdirs .pro file that can be read in both the foo and bar .pro files.

I've tried to set an environment variable with:

export TEST=something

but that does not work, message($$(TEST)) always shows nothing (like TEST is unset).

2
As an aside I am using OS X 10.4 - Dan O
lists.trolltech.com/qt-interest/2005-02/thread00337-0.html seems like a possibility for doing what i want to do! - Dan O
Troubadours answer may answer the question you had in mind, but it does not answer the question you posted (which is much more interesting). user176164 was on the right track. But it is Matt who has the correct answer, see here. - Patrick Fromberg

2 Answers

18
votes

Just place them in a common .pri file eg. common.pri and use qmake's own include syntax to include it i.e.

include(path/common.pri)

where path is the path to common.pri relative to the including .pro file.

11
votes

Another option is to place the common variables in a file called ".qmake.cache" stored in the root dir of the project. This way you don't need to include any .pri files in the subdir projects.