PDA

View Full Version : Need to know current file in qmake



juannm
4th April 2008, 13:50
Hello, I'm thinking about what would be the best way for including othe dependency .pri's from my .pro / .pri files.

At the moment I have the following (in my project.pro file):


!include($$PWD/../dir1/dependency1.pri) {
message("project.pro: can't find $$PWD/../dir1/dependency1.pri")
}
!include($$PWD/../dir2/dependency2.pri) {
message("project.pro: can't find $$PWD/../dir2/dependency2.pri")
}

As you can see, I make use of the undocumented PWD variable.

Have in mind that we are talking about 50 or more .pri files, which colud be nested (one pri including others)

But after reading better the qmake's documentation, and in my effor for doing this more generic, I thought about doing his:



THIS = project.pro
...
DEPENDS = $$PWD/../dir1/dependency1.pri
DEPENDS += $$PWD/../dir2/dependency2.pri
for(d, DEPENDS):!include($$d):error($$THIS: can't find $$d)


The problem? well, the variable THIS is overwritten by the last included .pri before the one which failed. So, in short, what I would need is an undocumented variable which always contains the current .pro or .pri file name, just like PWD always contains the current .pro or .pri directory.

Does something like that exist? If not, could you please post your thoughts about including .pri(s) in a qmake project?

Thank you,

Juan Navarro