OlivierLDff / Qaterial

🧩 Collection of Material Components based on QtQuickControls2.
https://olivierldff.github.io/Qaterial/
MIT License
301 stars 57 forks source link

[CMake]: Use versionless targets from Qt 5.15 #80

Closed Milerius closed 3 years ago

Milerius commented 3 years ago

in order to facilitate transition to Qt6:

https://doc-snapshots.qt.io/qt6-dev/cmake-qt5-and-qt6-compatibility.html#versionless-targets

Milerius commented 3 years ago
In addition to the existing imported targets, Qt 5.15 introduced versionless targets. That is, to link against Qt Core one can both reference Qt6::Core, or Qt::Core

We probably want the same for: https://github.com/OlivierLDff/QOlm/blob/master/CMakeLists.txt#L105

OlivierLDff commented 3 years ago

Nice one, have you tried with Qt6 beta yet? Can you open the same PR for QOlm?

You missed some CMakelists : https://github.com/OlivierLDff/Qaterial/blob/95b0e8ae9fff157a55b0481ae23583d186c02c18/res/Fonts/CMakeLists.txt#L59-L65

https://github.com/OlivierLDff/Qaterial/blob/1e7ed989b4045a93600d7569a694828817c0eaf3/res/Icons/CMakeLists.txt#L66-L72

https://github.com/OlivierLDff/Qaterial/blob/2c1a9bfc5e44eb6f447f345f2a3cda61661b55e9/tools/HotReload/lib/CMakeLists.txt#L46-L65

https://github.com/OlivierLDff/Qaterial/blob/2c1a9bfc5e44eb6f447f345f2a3cda61661b55e9/tools/HotReload/lib/CMakeLists.txt#L77

https://github.com/OlivierLDff/Qaterial/blob/74d5b8be1c8f8e6c627b09fba2daaf8de5e7c600/tools/HelloWorld/CMakeLists.txt#L35

There is the find_package problem still. But let's first merge the target_link_libraries then the find_package since it seems to require some boilerplate code.

https://github.com/OlivierLDff/Qaterial/blob/2c1a9bfc5e44eb6f447f345f2a3cda61661b55e9/tools/HotReload/lib/CMakeLists.txt#L25

Milerius commented 3 years ago

@OlivierLDff I didn't try the beta yet, but i'm thinking about preparing a nice transition and i think the first step is the new target approach.

Yes sorry for the missing files i didn't it through the web github interface i will fix them too

Milerius commented 3 years ago

I think it's done for this pr @OlivierLDff

Milerius commented 3 years ago

Me in my case I would like to switch to Qt 6 in December, but from what I saw all web modules will not be available in Qt6 so I would need to have Qt5 support

Basically: QtWebEngine QtWebView and so on

So yes we will basically need to have some if conditions to pickup good Qt Version but in your case all the modules that you use in this library are supported by Qt6 (Only web engine is missing i guess)

Second problem is the CI part we will basically need to have both Qt5 and Qt6 installed for a project that mix both modules

OlivierLDff commented 3 years ago

I would like to use Qt6 as soon as possible to reduce cmake & qml register type boiler plate code. But same i'm missing the module Multimedia for an application. I think i will try to build QaterialGallery with Qt6 when it will be available and support both Qt5.15 and Qt6 while Qt5.15 is still LTS.

Thanks for the PR!

Milerius commented 3 years ago

Yes anyway i'm sure with some boilerplate CMake code we can (in an easy way) have support for both Qt5.15 / Qt6 and even both at the same time just need to investigate a bit

Just try to not break everything when switching to Qt6 so i can still use it ahah :D

I said December because official release will be at this moment

OlivierLDff commented 3 years ago

moc is already annoying when mixing qt5 from different version, so i don't think it will support binary compatibility between qt5 and qt6.

Better wait for Qt6.1 or 6.2