[Development] How I'm using qtchooser
Hausmann Simon
Simon.Hausmann at digia.com
Tue Dec 18 09:59:16 CET 2012
Did you forget to push / integrate qtchooser by chance? The repo is empty for me :)
Simon
________________________________________
From: development-bounces+simon.hausmann=digia.com at qt-project.org [development-bounces+simon.hausmann=digia.com at qt-project.org] on behalf of Thiago Macieira [thiago.macieira at intel.com]
Sent: Tuesday, December 18, 2012 8:33 AM
To: development at qt-project.org
Subject: [Development] How I'm using qtchooser
Clone https://codereview.qt-project.org/p/qt/qtchooser
Run:
make bindir=$HOME/bin install
Packagers, please install as:
make INSTALL_ROOT=<insert-install-root-variable-here> install
For example, on my Mac:
$ qt
Not using Qt.
$ ls .config/qtchooser
5-frameworks.conf 5-no-frameworks.conf
$ qt <press TAB>
5-frameworks 5-no-frameworks none
$ qt 5-frameworks
Using Qt 5-frameworks
$ echo $QT_SELECT
5-frameworks
$ echo $QTLIBDIR
/Users/tjmaciei/obj/qt/qt5-frameworks/qtbase/lib
$ echo $QTOBJDIR
/Users/tjmaciei/obj/qt/qt5-frameworks/qtbase
$ echo $QTSRCDIR
/Users/tjmaciei/src/qt/qt5-frameworks/qtbase
$ ls -l `which qmake`
lrwxr-xr-x 1 tjmaciei staff 9 Dec 17 22:47 /Users/tjmaciei/bin/qmake ->
qtchooser
$ qmake -v
QMake version 3.0
Using Qt version 5.0.0 in /Users/tjmaciei/obj/qt/qt5-frameworks/qtbase/lib
$ moc -v
Qt Meta Object Compiler version 69 (Qt 5.0.0)
$ uic3 -v
uic3: could not exec '/Users/tjmaciei/obj/qt/qt5/qtbase/bin/uic3': No such file
or directory
My "qt" function is:
function qt()
{
# Get or set the Qt version
if [ $# -eq 0 ]; then
# Get the Qt version
if [ -z "$QT_SELECT" ]; then
echo "Not using Qt."
else
echo "Using Qt $QT_SELECT"
fi
else
# Set the working Qt version
unset QT_SELECT
local QTTOOLDIR
test x$1 = xnone || eval $(qtchooser -qt=$1 -print-env) || return $?
# Remove old
removefrom LD_LIBRARY_PATH $QTLIBDIR
removefrom PKG_CONFIG_PATH $QTLIBDIR/pkgconfig
# Add new
if [ x$1 != xnone ]; then
{ pushd $QTLIBDIR/.. && QTOBJDIR=$PWD &&
updatedirs && QTSRCDIR=$srcdir && popd; } > /dev/null
2>/dev/null
QTSRCDIR=${QTSRCDIR-$QTOBJDIR}
addto LD_LIBRARY_PATH $QTLIBDIR
addto PKG_CONFIG_PATH $QTLIBDIR/pkgconfig
echo "Using Qt $1"
export LD_LIBRARY_PATH PKG_CONFIG_PATH
export QTOBJDIR QTSRCDIR QTLIBDIR QT_SELECT
else
unset QTOBJDIR QTSRCDIR QTLIBDIR
echo "Not using Qt"
fi
fi
}
The removefrom and addto functions are trivial and left as an exercise for the
reader. The updatedirs function is part of my shadow build manipulation and it
updates $objdir and $srcdir indicating where the sources and binaries are. You
may skip that line or update to whatever you currently use.
The zsh completion function is:
function _qt() {
_wanted arguments expl 'Disable Qt' compadd "none"
qtchooser -list-versions | while read ver; do
_wanted arguments expl "Qt version $ver" compadd $ver
done
return 1
}
compdef _qt qt
--
Thiago Macieira - thiago.macieira (AT) intel.com
Software Architect - Intel Open Source Technology Center
More information about the Development
mailing list