Hi,

I've been working on a patch to make it easier to use CMake with a 
statically built Qt 5:

 https://codereview.qt-project.org/#change,56215

A complexity arises in that all Qt 5 applications must load a platform 
plugin. If Qt is built statically, the platform plugin must be loaded by 
using the Q_IMPORT_PLUGIN macro.

Rather than forcing all Qt-using code to have a shared/static specific 
snippet, qmake generates a small file like this:

 #include <QtPlugin>            
 Q_IMPORT_PLUGIN(QXcbIntegrationPlugin) // Or Win plugin on Windows.

and compiles it into the executable. 

In my patch above I tried a similar approach by creating a static library 
with the above snippet and adding it to the link interface of Qt5::Gui. 
However, the plugin import code does not get executed at runtime. I assume 
the linker ignores the code because the executable doesn't use any symbols 
from it.

The solution would be to generate an OBJECT library instead of a static 
library. However, it is not possible to link to an OBJECT library currently. 

I was wondering why that is, and if it can be changed? Alternatively, can 
you think of any other solutions for this? I don't want to require people to 
have to use something like:

 add_executable(myexe ${Qt5StaticObjectPluginLoader} main.cpp)

Thanks,

Steve.


--

Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/cgi-bin/mailman/listinfo/cmake-developers

Reply via email to