Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. Setting global variable in subdirs template
QtWS25 Last Chance

Setting global variable in subdirs template

Scheduled Pinned Locked Moved Solved Qt Creator and other tools
qmakesubdirsvariable settin
6 Posts 3 Posters 5.6k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    koahnig
    wrote on 15 Nov 2016, 14:12 last edited by koahnig
    #1

    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?

    Vote the answer(s) that helped you to solve your issue(s)

    K 1 Reply Last reply 15 Nov 2016, 15:55
    1
    • K koahnig
      15 Nov 2016, 14:12

      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?

      K Offline
      K Offline
      kshegunov
      Moderators
      wrote on 15 Nov 2016, 15:55 last edited by kshegunov
      #2

      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.

      Read and abide by the Qt Code of Conduct

      K 1 Reply Last reply 15 Nov 2016, 18:00
      1
      • K kshegunov
        15 Nov 2016, 15:55

        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.

        K Offline
        K Offline
        koahnig
        wrote on 15 Nov 2016, 18:00 last edited by
        #3

        @kshegunov

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

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

        Vote the answer(s) that helped you to solve your issue(s)

        1 Reply Last reply
        0
        • S Offline
          S Offline
          SGaist
          Lifetime Qt Champion
          wrote on 15 Nov 2016, 21:46 last edited by
          #4

          Hi,

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

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          K 1 Reply Last reply 16 Nov 2016, 15:43
          1
          • S SGaist
            15 Nov 2016, 21:46

            Hi,

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

            K Offline
            K Offline
            koahnig
            wrote on 16 Nov 2016, 15:43 last edited by
            #5

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

            Vote the answer(s) that helped you to solve your issue(s)

            1 Reply Last reply
            0
            • S Offline
              S Offline
              SGaist
              Lifetime Qt Champion
              wrote on 16 Nov 2016, 16:06 last edited by
              #6

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

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              1

              2/6

              15 Nov 2016, 15:55

              4 unread
              • Login

              • Login or register to search.
              2 out of 6
              • First post
                2/6
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved