Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. qmake and 'include' function

qmake and 'include' function

Scheduled Pinned Locked Moved Unsolved General and Desktop
6 Posts 3 Posters 2.0k 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.
  • canellasC Offline
    canellasC Offline
    canellas
    wrote on last edited by canellas
    #1

    Hi! I have a development directory structure more or less like this:

    /
    /common
    common.pro
    /a
    a.pro

    In 'a.pro' I want to include 'common.pro', and I want the paths referenced in common.pro be relative to 'a' directory.

    Does anyone know how to do it?

    Thanks!

    1 Reply Last reply
    0
    • G Offline
      G Offline
      Gerd
      wrote on last edited by
      #2

      Hi,
      just use
      include(../common/common.pro)

      in a,pro

      1 Reply Last reply
      0
      • canellasC Offline
        canellasC Offline
        canellas
        wrote on last edited by
        #3

        Thanks for your answer.

        I tried that, but the relative paths in 'common.pro' stay relative to where 'common.pro' is, and not to where 'a.pro' is.

        1 Reply Last reply
        0
        • G Offline
          G Offline
          Gerd
          wrote on last edited by Gerd
          #4

          Sorry, misunderstood the question..

          In that case you can use the qmake-variable

          _PRO_FILE_PWD_
          

          using a test with some testfiles like this:

          test.pro:

          TEMPLATE        = subdirs 
          SUBDIRS         += a
          SUBDIRS         += common
          

          a/a.pro:

          message("pwd is $$_PRO_FILE_PWD_")
          include(../common/common.pro)
          

          common/common.pro:

          message("pwd in common is $$_PRO_FILE_PWD_")
          
          

          gives this result:

          d:\zw\qmaketest>qmake -r
          Reading D:/zw/qmaketest/a/a.pro
          Project MESSAGE: pwd is D:/zw/qmaketest/a
          Project MESSAGE: pwd in common is D:/zw/qmaketest/a
          Project MESSAGE: pwd is D:/zw/qmaketest/a
          Project MESSAGE: pwd in common is D:/zw/qmaketest/a
          Project MESSAGE: pwd is D:/zw/qmaketest/a
          Project MESSAGE: pwd in common is D:/zw/qmaketest/a
          Reading D:/zw/qmaketest/common/common.pro
          Project MESSAGE: pwd in common is D:/zw/qmaketest/common
          Project MESSAGE: pwd in common is D:/zw/qmaketest/common
          Project MESSAGE: pwd in common is D:/zw/qmaketest/common
          

          That shou give you a hint
          (edit: added some code-tags)

          1 Reply Last reply
          0
          • speqtrS Offline
            speqtrS Offline
            speqtr
            wrote on last edited by
            #5

            Hi,

            you can try to:

            • rename common.pro to common.pri,
            • include it in your a.pro like this:
            !include(common.pri) {
                error("Ooops..! common.pri is missing")
            }
            
            • inside common.priuse _PRO_FILE_PWD_ variable

            In this case, when you include common.pri inside your a.pro, _PRO_FILE_PWD_ variable will point to the a.pro directory.
            If you later include common.pri inside b.pro, _PRO_FILE_PWD_ will point to the b.pro directory.
            And so on...

            You can read more on the qmake variables page.

            Hope this helps :)

            1 Reply Last reply
            0
            • canellasC Offline
              canellasC Offline
              canellas
              wrote on last edited by
              #6

              it worked using PRO_FILE_PWD variable! Thanks a lot!

              1 Reply Last reply
              0

              • Login

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