Have you seen the output of the command-line qmake -query
...?
On my system it gives (removed much of the output for clarity):
~ sez$ env PATH=$HOME/build/qt5/qtbase/bin qmake -query
QT_SYSROOT:
QT_INSTALL_PREFIX:/usr/local/Qt-5.2.0
QT_INSTALL_DATA:/usr/local/Qt-5.2.0
QT_INSTALL_HEADERS:/usr/local/Qt-5.2.0/include
QT_INSTALL_LIBS:/usr/local/Qt-5.2.0/lib
QMAKE_SPEC:macx-clang
QMAKE_VERSION:3.0
QT_VERSION:5.2.0
Its less verbose in earlier versions. You can query individual variables like this:
~ sez$ env PATH=$HOME/build/qt5/qtbase/bin qmake -query QT_INSTALL_HEADERS
/usr/local/Qt-5.2.0/include
does that do what you need? Beware of the fact that it will report the location the files are installed to by the make install
at the time Qt was built. That means that if you have built Qt but not run "make install" the results of qmake -query won't give you a useful answer.
If you have built from sources and want to use then out of that build directory, then you'd need to run ./configure -prefix=$PWD
, and then make install
.
EDIT:
For one of my qmake generated Makefiles I have -
INCPATH = -I/usr/local/Qt-5.2.0/mkspecs/macx-clang -I/Users/sez/depot/plistinator/src -I/usr/local/Qt-5.2.0/lib/QtWidgets.framework/Versions/5/Headers -I/usr/local/Qt-5.2.0/lib/QtXml.framework/Versions/5/Headers -I/usr/local/Qt-5.2.0/lib/QtGui.framework/Versions/5/Headers -I/usr/local/Qt-5.2.0/lib/QtCore.framework/Versions/5/Headers -I. -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/System/Library/Frameworks/OpenGL.framework/Versions/A/Headers -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/System/Library/Frameworks/AGL.framework/Headers -I. -I. -F/usr/local/Qt-5.2.0/lib
This is dependent on which Qt modules have been specified for example
QT += widgets xml
Given that information you could reconstruct the above INCPATH using whatever environment you're automating in, eg for bash shell expressions part of one might be
XML_INC=$(qmake -query QT_INSTALL_LIBS)/QtXml.framework/Versions/5/Headers
To get the mkspecs include you could do
MKSPEC_INC=$(qmake -query QT_INSTALL_PREFIX)/mkspecs/$(qmake -query QMAKE_SPEC)
With respect to the GL paths in the SDK those will always be included for Qt, so you could construct them by capturing the output from gcc -v
.
Then combine all these *_INC vars into the final result.
Coming up with a complete script for this is beyond the scope of this answer but I think this approach would get you there. I can't think of an easier way to do what you want without actually generating the Makefile.