Results 1 to 6 of 6

Thread: How to get current dir using qmake?

  1. #1
    Join Date
    Dec 2006
    Posts
    426
    Thanks
    8
    Thanked 18 Times in 17 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default How to get current dir using qmake?

    Hi,

    I have a pro file in my local work area, which includes an pri file somewhere else, as in

    include( /apps/system/common.pri )

    I run the qmake on my local pro file to create a makefile, how can I determine the full path name of the pro file from within the common.pri file?

    The $$PWD will return "/apps/system", which is the location of the common.pri file, but I need to know where the pro file is.

    Thanks

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,372
    Thanks
    3
    Thanked 5,019 Times in 4,795 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How to get current dir using qmake?

    You might try reading the path from a variable, like so:
    Qt Code:
    1. PATHNAME=$$PRO_PATH
    To copy to clipboard, switch view to plain text mode 
    and making sure the variable PRO_PATH is defined in the .pro file before you include the .pri file:
    Qt Code:
    1. PRO_PATH=$$PWD
    2. include(/apps/system/common.pri)
    To copy to clipboard, switch view to plain text mode 

  3. #3
    Join Date
    Dec 2006
    Posts
    426
    Thanks
    8
    Thanked 18 Times in 17 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: How to get current dir using qmake?

    Thanks, that is what I did, but I don't like it.

    It requires every pro file to have "PRO_PATH=$$PWD". Is there any other way to determine the caller's location?

    I try system( pwd ) inside /apps/system/common.pri, it returns "/apps/system/", which is the same as "PWD" and is not what I am looking for...

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,372
    Thanks
    3
    Thanked 5,019 Times in 4,795 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How to get current dir using qmake?

    Because it is interpreted in the .pri file. You won't be able to do that without doing the check in the .pro file. I assure you it has benefits

  5. #5
    Join Date
    Jan 2006
    Posts
    128
    Thanked 28 Times in 27 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to get current dir using qmake?

    Think about not putting it into a pri file but creating a feature.

    I have a rather nice setup involving a ".qmake.cache" and features...
    Check it out:template.tar.bz2

    Not yet well documented...but contains some stuff which might be interesting for the wiki...perhaps when I have some time ;-)

  6. #6
    Join Date
    Jan 2006
    Posts
    128
    Thanked 28 Times in 27 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Wink Re: How to get current dir using qmake?

    And, just in case you were interested in a straight answer instead of the "do you really need that what you ask for" answer I gave you above:
    Check out

    $$_PRO_FILE_PWD_
    or
    $$OUT_PWD

    Not nice, nor documented and I have only checked to see it is in 4.2.2 but this (or rather one of these, depending of use-case) seems to be what you asked for ;-)
    Last edited by camel; 7th January 2007 at 20:51. Reason: found the OUT_PWD

Similar Threads

  1. Flex, Bison and qmake
    By Hydragyrum in forum Qt Programming
    Replies: 5
    Last Post: 2nd May 2011, 15:52
  2. qmake and mingw trouble
    By krivenok in forum Qt Programming
    Replies: 8
    Last Post: 12th February 2009, 21:58
  3. qmake to build both 32-bit and 64-bit
    By lni in forum Qt Programming
    Replies: 8
    Last Post: 12th December 2006, 19:35
  4. Replies: 5
    Last Post: 13th March 2006, 20:22
  5. linking user space and kernel space programs with qmake
    By zielchri in forum Qt Programming
    Replies: 9
    Last Post: 8th March 2006, 23:11

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.