Setting global variable in subdirs template


  • Moderators

    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?


  • Qt Champions 2016

    Hey,
    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 qmake with that environment set:

    $ MY_ENV_PATH=/some/destination/path /path/to/qmake project.pro
    

    Hope that helps.
    Kind regards.


  • Moderators

    @kshegunov

    I had tried already the first option and it does not work.

    Going through the environment does work. It looks a bit strange.


  • Lifetime Qt Champion

    Hi,

    IIRC, you can put these variables in file named .qmake.cache at the root of your project.


  • Moderators

    @SGaist

    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.


  • Lifetime Qt Champion

    My bad ! It was .qmake.conf that you can use for your common variables.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.