Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a Qt install path variable that I can use in the .pro file?

I want to copy an audio plugin to my target directory since I need it for deployment.

It lives in <PATH_TO_QT_INSTALL>\gcc\plugins\audio

I don't know what variable I can use to reference the install path inside my /pro file.

The line of code I want to add is something like this:

QMAKE_PRE_LINK += cp $$PATH_TO_QT_INSTAL/gcc/plugins/audio/* $$DESTDIR/lib || :;

There is an environment variable called %{CurrentProject:QT_INSTALL_BINS} that gets me to $$PATH_TO_QT_INSTAL/gcc/bin which I could use, but I seem to be only able to use this in the qt creator gui build settings which is no good to me since these settings live in the .pro.user file. WHY doesn't qt have a generic build settings mechanism : ( ... (that's just a side question, no need to answer)

My question is how can I reference the qt install path in my pro file, is there a variable that can do this, or any other way?

like image 855
code_fodder Avatar asked May 26 '16 06:05

code_fodder


Video Answer


3 Answers

The variable QT_INSTALL_PREFIX seems to be what you want, but it highly depends on how Qt has been installed.

For more fine-tuning depending on the exact qt directory you're interested in, the following command will give you an exhaustive list of persistent properties of qt:

/path/to/qmake -query

# Output
# QT_INSTALL_PREFIX:/path/to/Qt
# QT_INSTALL_ARCHDATA:...
# ...

The already mentioned QT_INSTALL_LIBS is listed there for example. Once you find the variable corresponding to your usecase, you can use it in your .pro file as it was already mentioned, i.e. with $$[QT_INSTALL_PREFIX] for example.

Note: from the qmake documentation, squared brackets should be used for qmake properties ($$[])

Versions: tested with Qt 5.6.2 and qmake 3.0

like image 66
jmon12 Avatar answered Nov 09 '22 07:11

jmon12


Another solution (may be not as fancy as above with $[QT_INSTALL_LIBS] but I used it already for quite a long time:

TEMPNAME = $${QMAKE_QMAKE}
QTPATH = $$dirname(TEMPNAME) 

then you can reference it like this (for example to access some private headers) or to copy things:

INCLUDEPATH += $$QTPATH/../../Src/qtbase/src/sql/kernel
like image 36
evilruff Avatar answered Nov 09 '22 05:11

evilruff


For Qt4 and Qt5, looks like $$[QT_INSTALL_LIBS] is what you want? Can't confirm first-hand this works though.

See https://forum.qt.io/topic/65778/qmake-and-qt-installation-root-directory/2 and http://doc.qt.io/qt-4.8/qmake-advanced-usage.html.

like image 26
eclarkso Avatar answered Nov 09 '22 05:11

eclarkso