Determine which qt libraries/modules are available [qmake]
Is there a clean way to detect within a pro file which qt libraries/modules (e.g. 3d, gui) are available?
We have a project which consists of several subprojects. Some of the subprojects need to be configured with the 3d module or the gui lib.
Given the qt libraries are build with the option –no-gui and no Qt3d module; We still want to have subprojects build which don’t depend on those (3d, gui) libraries.
Is there a chance qmake can make this configuration automatically? I think REQUIRES http://qt-project.org/doc/qt-5.0/qmake-variable-reference.html#requires is going in the right direction, but I couldn’t figure out how to use it exactly for this purpose. Do you have any suggestions?
I think it's possible in CMake. I don't know of any built-in mechanism like that in qmake, but you can always get around it by declaring a few new variables. For example, declare isGui and isQt3d in some .pri file that you include in your projects. Then, wrap the parts of code that require the gui in:
QT += gui
SOURCES += ...
And build your project with or without those flags depending on the situation. Not a fully automated solution, but might partially solve the problem.
Ah, what a coincidence. A recent post on Qt Creator mailing list has a nice clue that could help you:
SUBDIRS += file
Again, not exactly what you need, but might solve the issue.
Thank you for your Ideas - They are much appreciated!
We found a neat solution. It seems there is this new qmake function "qtHaveModule(<module>): ..." recently introduced. So we solved the problem by utilizing: