[Solved] Qt Creator: How to refer to the Build directory path in a .pro file?
-
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
-
.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.).
-
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.
-
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).
-
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.
-
Thanks to you also, I have not encountered OUT_PWD yet. It might come in handy :D