Apologies that this won't tread correctly (and for directly CC'ing the
three participants); I only signed up to the mailing list after I saw
this conversation. I'm an MSYS2 developer (and I occasionally hack on
Qt build system issues). I've spent a lot of time working on our qt5
and qt5-static packages and a little time working on our cmake
packages, so I'm quite familiar with the CMake and Qt5 static issues
you are discussing, in fact it's the most recent thing I've hacked on
for these packages. My patches can be found at:

[patches 33 .. 41 are mostly cmake related]
.. and:

Stephen Kelly wrote:
> Ghyslain Leclerc wrote:
> > Here are a few questions for the list (hoping someone more knowledgable
> > than me will read this and help):
> >
> > 1) Am I right when I say CMake, Qt and static linking don’t mix ?
> They should mix fine.

.. actually, you did submit a patch to Qt5 for this:
.. but then you reverted it:

I un-reverted it for MSYS2, with the logic given in my commit message.
I'll not paste it here as you can read it there, but please correct me
if I'm wrong regarding INTERFACE_LINK_LIBRARIES:

Norbert Pfeiler wrote:
> Currently you have to define »QT_STATIC«

You shouldn't need to do this. If you use MSYS2's
mingw-w64-{i686,x86_64}-qt5-static then that will be defined for you.

> and explicitly include your required plugins in the code to get it working

More on this below.

Norbert Pfeiler wrote:

> For Windows it’s like this:
> #if defined(Q_OS_WIN) && defined(QT_STATIC)
> #include <QtPlugin>
> Q_IMPORT_PLUGIN(QWindowsIntegrationPlugin)
> #endif

Again, if you use MSYS2's mingw-w64-{i686,x86_64}-cmake then you
should not need to do this either, because of

Stephen Kelly wrote:

> CMake 3.1 learned a new feature specifically so that this would become
> easier in the future:
> http://thread.gmane.org/gmane.comp.programming.tools.cmake.devel/7970
> qmake generates a file like the above for you and compiles it and links it
> into your application for you in the static version.
> With
> http://www.cmake.org/cmake/help/v3.1/prop_tgt/INTERFACE_SOURCES.html
> Qt can do the same, but someone would have to patch Qt to do so. Something
> for the future... :)

.. so I guess that overall, my patches are far from ideal (still they
achieve their goal for us!), in particular I didn't like adding code
to cmQtAutoGenerators.cxx as that seems like something that shouldn't
be hard-coded into a general purpose build system, but I'm pleased to
read that the plan is to generalise this kind of thing going forward
(I think that's the gist - clearly I'm no expert in CMake).

As a side node, I actually tried to use a Digia-provided (I think) Qt
static build for something work-related about a year ago, and because
it requires a specific version of the msvc++ runtime I don't think it
fits any useful definition of 'static'. Qt static built with MinGW-w64
does though as the msvcrt.dll we use is present on all Windows
releases all the way back to Windows XP. Maybe I used the wrong one
though, as the Qt SDK seems to be static enough.

Best regards,

Ray Donnelly.

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 

Follow this link to subscribe/unsubscribe:

Reply via email to