cmake: Use the official CMake variable for building as a static plugin.
ClosedPublic

Authored by mart on Jan 15 2018, 5:25 PM.

Details

Summary

This is the first step in actually creating a valid Qt static plugin.

Currently, when used as a static library, it is expected to be a
subdirectory of the project instead of a "proper" Qt plugin. This
patch and the ones that follow aim to make Kirigami a plugin just
as Qt official ones.

Test Plan

builds and works in both modes, however KirigamiPlugin::registerTypes()
still seems to be needed, which we want to get rid of in the end

Diff Detail

Repository
R169 Kirigami
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
mart created this revision.Jan 15 2018, 5:25 PM
Restricted Application added a project: Kirigami. · View Herald TranscriptJan 15 2018, 5:25 PM
Restricted Application added a subscriber: plasma-devel. · View Herald Transcript
mart requested review of this revision.Jan 15 2018, 5:25 PM
apol added a subscriber: apol.Jan 16 2018, 12:19 AM

I wonder if it would make sense to always ship the qml files as qrc in the plugin. Have you considered it?

src/CMakeLists.txt
47

I'd reuse the target_link_libraries calls. Better duplicate minimum. You can have an extra target_link_libraries(kirigamiplugin PRIVATE KF5::Kirigami2) if needed.

src/controls/qmldir
2 ↗(On Diff #25405)

Why is it commented?

In D9892#191590, @apol wrote:

I wonder if it would make sense to always ship the qml files as qrc in the plugin. Have you considered it?

(this code is originally from me, then improved by notmart and is part of the greater work to ship static appimages)

I did consider it and went ahead in ring-kde and put every QML in QRC even in non static builds. I think it makes sense, but makes debugging a bit harder and I didn't want to change too much things to fix the static plugin. Shipping assets in QRC doesn't seem to be common outside of some KDE projects that take cross platform more seriously.

apol added a comment.Jan 16 2018, 12:35 AM

I did consider it and went ahead in ring-kde and put every QML in QRC even in non static builds. I think it makes sense, but makes debugging a bit harder and I didn't want to change too much things to fix the static plugin. Shipping assets in QRC doesn't seem to be common outside of some KDE projects that take cross platform more seriously.

I put all qml files in a qrc file for Discover, hasn't been an issue.

mart added a comment.Jan 16 2018, 9:56 AM
In D9892#191590, @apol wrote:

I wonder if it would make sense to always ship the qml files as qrc in the plugin. Have you considered it?

may make sense...
i would save it for another poatch tough this is big enough already :)

apol added a comment.Jan 16 2018, 9:58 AM
In D9892#191707, @mart wrote:
In D9892#191590, @apol wrote:

I wonder if it would make sense to always ship the qml files as qrc in the plugin. Have you considered it?

may make sense...
i would save it for another poatch tough this is big enough already :)

Okay, can you go through the questions I put in this patch?

I tried the patch on my CI and it compiled and linked. I also reviewed the changes between my patchset and this diff and approve the change, I also agree with Apol about the target_link_libraries issue. It should be mutualized between the if and else. So "almost ship it!"

mart updated this revision to Diff 25589.Jan 18 2018, 12:59 PM
  • don't duplicate target_link_libraries
  • properly use the static plugin in the example
  • the pro makes a static library
  • use proper static plugins for the cmake example
  • toplevel qmake with subfolders
  • proper name for executable
mart added a comment.Jan 18 2018, 1:00 PM

now the library definition is not duplicated
and both the cmake and qmake example do usa the static plugin

mart updated this revision to Diff 25594.Jan 18 2018, 2:29 PM

try to diff against the proper stuff

This revision was not accepted when it landed; it landed in state Needs Review.Jan 19 2018, 10:21 AM
This revision was automatically updated to reflect the committed changes.
croick added a subscriber: croick.Jan 21 2018, 12:26 PM
croick added inline comments.
src/CMakeLists.txt
69

When trying to install it using kdesrc-build, it complains about not finding the specified directory. I assume its supposed to be available?