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?
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
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
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With