views:

193

answers:

2

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).

+4  A: 

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.

J-P Nurmi
The fact that this will be a hidden file on my operating system is a bit of a bummer, but at least I don't have to taint my subdir projects with weird includes, thanks!
Dan O
+4  A: 

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.

Troubadour
I ended up doing this in the end, because qmake only searches for the .qmake.cache in the current directory or its parent. This was too restrictive for me.
Dan O