[CMake] Mixed linking
Stephen Kelly
steveire at gmail.com
Sat Feb 21 04:53:33 EST 2015
Ghyslain Leclerc wrote:
> Thanks for all the insight. I have been looking at this and quite a few
> posts (mostly from you !) to try and understand. I think I get most of
> it.
>
> That being said, I finally got a static executable for my application on
> my mac. What I did is build my application using qmake, get the linker
> command and manually find every library using cmake in order to recreate
> the linker command from qmake (I don’t think it makes a difference, but
> I’m not sure so I even kept the library order the same).
Yes, I think it makes a difference. It also makes a difference whether
find_library finds the exact same binary which Qt statically links or not.
The inability to determine which static library (by exact path) is linked by
the Qt libraries is the reason the Qt5 CMake files don't list the static
libraries in their INTERFACE_LINK_LIBRARIES. Your find_library calls are not
a fully generic solution because find_library might find a different binary
to what Qt is linked to.
> This seems like a lot of work to get what I want… But if it does the job.
> The fun part will be to see what I need on Windows and then put
> conditionals around that and all.
>
> If I misunderstood something and there is an easier way to get a static
> executable from using static qt from CMake, please let me know.
What I referred to with INTERFACE_SOURCES was just about automatically
linking in the platform plugin in a static build. That is provided by Qt,
so ew know the full path, but we need to generate a file which you compile
into the executable so that your executable uses a symbol from it. Otherwise
the linker discards it. So my message was just saying that that part can be
made simpler.
Thanks,
Steve.
More information about the CMake
mailing list