qmake and Qt installation root directory
Swen Laur last edited by
How could I refer to Qt installation root directory available in shell as qmake -v. Is there a special qmake variable or a way to store the outcome of qmake -v in a variable.
Paul Colby last edited by Paul Colby
Is there a special qmake variable or a way to store the outcome of qmake -v in a variable.
Assuming you want to store the outcome in a qmake variable (as opposed to, for example, a shell script variable), then there's a few built-in variables that probably have what you're after.
The special $$[...] operator can be used to access qmake properties
So, for example:
paul@paul-XPS-13-9343:~/tmp$ cat messages.pro message(Qt version: $$[QT_VERSION]) message(Qt is installed in $$[QT_INSTALL_PREFIX]) message(Qt resources can be found in the following locations:) message(Documentation: $$[QT_INSTALL_DOCS]) message(Header files: $$[QT_INSTALL_HEADERS]) message(Libraries: $$[QT_INSTALL_LIBS]) message(Binary files (executables): $$[QT_INSTALL_BINS]) message(Plugins: $$[QT_INSTALL_PLUGINS]) message(Data files: $$[QT_INSTALL_DATA]) message(Translation files: $$[QT_INSTALL_TRANSLATIONS]) message(Settings: $$[QT_INSTALL_CONFIGURATION]) message(Examples: $$[QT_INSTALL_EXAMPLES]) paul@paul-XPS-13-9343:~/tmp$ qmake Project MESSAGE: Qt version: 5.4.2 Project MESSAGE: Qt is installed in /usr Project MESSAGE: Qt resources can be found in the following locations: Project MESSAGE: Documentation: /usr/share/qt5/doc Project MESSAGE: Header files: /usr/include/x86_64-linux-gnu/qt5 Project MESSAGE: Libraries: /usr/lib/x86_64-linux-gnu Project MESSAGE: Binary files (executables): /usr/lib/x86_64-linux-gnu/qt5/bin Project MESSAGE: Plugins: /usr/lib/x86_64-linux-gnu/qt5/plugins Project MESSAGE: Data files: /usr/share/qt5 Project MESSAGE: Translation files: /usr/share/qt5/translations Project MESSAGE: Settings: /etc/xdg Project MESSAGE: Examples: /usr/lib/x86_64-linux-gnu/qt5/examples paul@paul-XPS-13-9343:~/tmp$ qmake -v QMake version 3.0 Using Qt version 5.4.2 in /usr/lib/x86_64-linux-gnu
So, at least on my installation, it looks like
$$[QT_INSTALL_LIBS]is equivalent to the path given in
Just out of curiosity, what you want that value for?
Paul Colby last edited by
Please note, in my post above, all the instances of
[should be preceded by two
$chars, not one... for some reason this forum (or my browser) keeps switching between showing one and two.
For example, they should look like
$ $ [QT_...](ignoring the spaces).
If in doubt, just look at the examples in http://doc.qt.io/qt-5/qmake-language.html#accessing-qmake-properties - they're formatted correctly.