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. [Solved] Qt Creator: How to refer to the Build directory path in a .pro file?
QtWS25 Last Chance

[Solved] Qt Creator: How to refer to the Build directory path in a .pro file?

Scheduled Pinned Locked Moved Qt Creator and other tools
6 Posts 2 Posters 29.7k 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.
  • J Offline
    J Offline
    jzhang636
    wrote on last edited by
    #1

    Hi experts-

    I know that in Qt Creator Build settings there is %{buildDir} to refer to the path of the build dirctory. Now I want to refer to the build path in the .pro file of a project. Is there any way like an envrironment variable that allows this use?

    Thanks in advance.

    Jason

    1 Reply Last reply
    1
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      .pro files work a bit differently. You can specify where you want to put the output files, and the build environment will respect that. For example, when you add this line to your file:
      @
      RCC_DIR= /some/dir
      @

      all resource files will be put there. Qt Creator, as an external IDE has some additional rights here: it can specify the base path for the output.

      For list of all qmake variables, see "qmake variable reference":http://qt-project.org/doc/qt-5.0/qtdoc/qmake-variable-reference.html. You should look for ones ending in DIR (DESTDIR, UI_DIR, RCC_DIR, OBJECTS_DIR, etc.).

      (Z(:^

      1 Reply Last reply
      0
      • J Offline
        J Offline
        jzhang636
        wrote on last edited by
        #3

        Thanks for your reply. But your suggestion seems not to be a solution to my problem: firstly, there seems not to be any variables that specify the build path in the qmake variable set; secondly, my application scenario is to use the same .pro file for two or more projects duplicated from a single base project, as in the case where branches are made from a trunk project; my goal is to keep the settings in the .pro files of the branch projects the same as those in the trunk project file. Where I make the changes in the settings is limited within Qt Creator. To meet this requirement, I hope that there would be a way like a qmake variable such that the different build directories of different branch projects can automatically be distinguished by the qmake program based on the Build settings made in Qt Creator.

        1 Reply Last reply
        0
        • sierdzioS Offline
          sierdzioS Offline
          sierdzio
          Moderators
          wrote on last edited by
          #4

          qmake does not know that Qt Creator exists, they are completely separate. I think you need to redesign your approach.

          You can access env variables in qmake, maybe that would help (try with $$PWD).

          (Z(:^

          1 Reply Last reply
          0
          • J Offline
            J Offline
            jzhang636
            wrote on last edited by
            #5

            You are right. qmake works independently of Qt Creator. So seeking a direct reference to the build directory path defined in Qt Creator from the .pro file does not work. Fortunately after searching in the qmake variable set, I found that $$OUT_PWD is the one that refers to a relevant path. I replaced the fixed directory path used in my .pro files with $$OUT_PWD variable, and found that it saves my life. The only thing that would be worthwhile to point out is that $$OUT_PWD refers to the build directory path of the very project under consideration. In a subdirs case, this would be a little bit confusing: the $$OUT_PWD of a subproject indicates the build directory path of the subproject, not the one of the parent - subdirs - project.

            Thanks a lot for your tips.

            1 Reply Last reply
            3
            • sierdzioS Offline
              sierdzioS Offline
              sierdzio
              Moderators
              wrote on last edited by
              #6

              Thanks to you also, I have not encountered OUT_PWD yet. It might come in handy :D

              (Z(:^

              1 Reply Last reply
              1

              • Login

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