Setting global variable in subdirs template
I have a project based on subdirs template.
Each of the subprojects is having a DESTIDR statement to a central folder. Now I try to change the destination temporily to another folder.
I have thought about setting DESTDIR in subdirs .pro and remove the individual DESTDIR folders.
However, apparently any variable set in the subdirs .pro is not accessible in the individual .pro files.
Any ideas how to do this?
Try setting your own variable and then eval it for each subproject, e.g.:
MY_OUT_PATH = /my/output/path TEMPLATE = subdirs # ...
and then (for each subproject):
DESTDIR = $$MY_OUT_PATH
If that doesn't work you could try setting an environment variable instead when
qmake's run, e.g. (in the subproject files):
DESTDIR = $$(MY_ENV_PATH)
which requires you to run
qmakewith that environment set:
$ MY_ENV_PATH=/some/destination/path /path/to/qmake project.pro
Hope that helps.
I had tried already the first option and it does not work.
Going through the environment does work. It looks a bit strange.
IIRC, you can put these variables in file named
.qmake.cacheat the root of your project.
Yes, you are right.
I had misinterpret "root of your project" at first. .qmake.cache has to be in one of the parent directories as the documentation says. If it is on the same level as the .pro file, it will not work.
Basically the environment approach and the .qmake.cache may be used.
My bad ! It was
.qmake.confthat you can use for your common variables.