I'm trying to guess Qt's libraries linkage in a project (.pro) file. I'm using various Qt framework directories: 32 and 64 bit Windows, Linux and Android builds; using static and shared Qt libraries. I've tried several way to check Qt's linkage, but nothing has worked so far.
Try 1:
qtConfig(static): message("Qt statically linked")
Try 2:
CONFIG(static, static|shared): message("Qt statically linked")
Try 3:
static: message("Qt statically linked")
I guessed all previous test would lead the same result, and thus show the "message" when selected Qt build is a static one, but I don't know if it's a Qt Creator issue or if I'm overriding *CONFIG
variables in project tree. I've checked it out too many times over and I haven't found any problem with that.
There's no such Qt-config feature as "static". So the right one is
!qtConfig(shared): message("Qt statically linked")
As an alternative you can do
!contains(QT.global.enabled_features, shared): message("Qt statically linked")
But this one is even less documented, so you're better to stick with qtConfig()
which essentially tests for the same thing.
No. 2 is a test of a build configuration of the user project itself, i.e. if you're building a static or shared library of your own.
No. 3 is a wrong way to do No. 2, because user's CONFIG
is allowed to contain both shared/static, debug/release etc. at the same time. And only the last one will matter.