qmake and 'include' function
-
Hi! I have a development directory structure more or less like this:
/
/common
common.pro
/a
a.proIn '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!
-
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.
-
Sorry, misunderstood the question..
In that case you can use the qmake-variable
_PRO_FILE_PWD_
using a test with some testfiles like this:
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) -
Hi,
you can try to:
- rename
common.pro
tocommon.pri
, - include it in your
a.pro
like this:
!include(common.pri) { error("Ooops..! common.pri is missing") }
- inside
common.pri
use_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 includecommon.pri
insideb.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 :)
- rename