Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow installing qt5 and qt6 versions in parallel #5

Closed
wants to merge 1 commit into from

Conversation

DarthGandalf
Copy link
Contributor

Why did you decide to open the library at runtime instead of linking to it at build time? The code would be much simpler then

@10110111
Copy link
Owner

10110111 commented Oct 4, 2022

Why did you decide to open the library at runtime instead of linking to it at build time?

This library was conceived as an alternative atmosphere model for Stellarium. And there the point was that if something goes very wrong, it'll be possible for the user to simply delete the file and use the legacy model. With direct linking it wouldn't be possible.

Besides, this lets me be less strict about binary compatibility, at least at this stage before version 1.0. The app can just check its ABI against the library ABI and give a sensible error message if it's not compatible.

@DarthGandalf
Copy link
Contributor Author

DarthGandalf commented Oct 5, 2022

And there the point was that if something goes very wrong, it'll be possible for the user to simply delete the file and use the legacy model

I see, makes sense.

The app can just check its ABI against the library ABI and give a sensible error message if it's not compatible.

This is not enough, unfortunately. Because you use std::function etc in the API, it's possible to e.g. build ShowMySky with libc++, but Stellarium with libstdc++ (or a different version of the same library/different compiler settings), and there still will be ABI issues.

I'm trying to make it possible to use the library without installation, instead building as part of build process of Stellarium, which makes that failure impossible. Of course, without breaking the other requirement

@10110111
Copy link
Owner

10110111 commented Oct 5, 2022

Because you use std::function etc in the API, it's possible to e.g. build ShowMySky with libc++, but Stellarium with libstdc++

Indeed it's possible. But for now the most problematic has been Qt, because Stellarium aims at supporting both 5 and 6, and apparently this is going to continue for quite long.

I'm trying to make it possible to use the library without installation

What exactly do you mean by installation — make install? Or something further like dpkg -i showmysky.deb? And how should the renaming into ShowMySky-Qt{5,6} help with this?

@DarthGandalf
Copy link
Contributor Author

DarthGandalf commented Oct 5, 2022 via email

@10110111
Copy link
Owner

10110111 commented Oct 5, 2022

How would parallel installation of qt5 and qt6 builds of Stellarium work in Gentoo? Or is it only supported for libraries? I've never seen such a feature on purely binary distributions like Debian or Fedora.

Yes, I do understand the usefulness of this for libShowMySky, but I don't quite like the renaming solution. Maybe it could be optional, like passing a custom suffix to cmake? Is there any traditional way of doing this (on Gentoo or anywhere)?

@DarthGandalf
Copy link
Contributor Author

DarthGandalf commented Oct 5, 2022 via email

@10110111
Copy link
Owner

10110111 commented Oct 5, 2022

What do you suggest instead of renaming?

This is the problem: I've never seen a precedent*, so I don't know how it can or should be done. I'd like to learn how similar cases are typically solved for other libraries. Usually a single system uses a single toolchain for an application and its dependencies.

* Well, there's Poppler, which has bindings for Qt{3,4,5,6}, glib, and just C++, but it also has a common library libpoppler.so, so this seems not to be an example.

@DarthGandalf
Copy link
Contributor Author

DarthGandalf commented Oct 5, 2022 via email

@10110111
Copy link
Owner

10110111 commented Oct 5, 2022

If you don't like this change, I guess I'm fine with applying something
like this patch locally for Gentoo for now.

I'm leaning towards accepting it, but need a few days more to think of better ways. In particular, I'd move the library name #ifs into the header rather than inserting it into the user code. E.g. put the following next to the ShowMySky_ABI_version definition in ShowMySky/api/AtmosphereRenderer.hpp.

#if QT_VERSION_MAJOR == 5
# define SHOWMYSKY_LIB_NAME "ShowMySky-Qt5"
#else
# define SHOWMYSKY_LIB_NAME "ShowMySky-Qt6"
#endif

@DarthGandalf
Copy link
Contributor Author

E.g. put the following next to the ShowMySky_ABI_version definition

Good idea. Done.

@10110111
Copy link
Owner

10110111 commented Oct 6, 2022

Is it feasible to make the target to query properties from be called ShowMySky::ShowMySky instead of ShowMySky::ShowMySky-QtX, while the project remains ShowMySky-QtX? Otherwise it seems like unnecessary verbosity in application's CMakeLists to list -QtX everywhere. It's quite unlikely that a single application will simultaneously link against both Qt5 and Qt6, so ShowMySky::ShowMySky seems quite unambiguous already.

@10110111
Copy link
Owner

10110111 commented Oct 7, 2022

My variant that satisfies the need to have Qt5 and Qt6 versions can be seen in my branch DarthGandalf-qtver. It includes your patch and a few tweaks. If you are OK with it, let me know and I'll merge it.

@10110111
Copy link
Owner

10110111 commented Oct 7, 2022

In fact, it would be the best if you updated your branch to my version so that I could merge it from GitHub UI, otherwise it'll likely not recognize the PR as merged due to the conflict resolution.

@DarthGandalf
Copy link
Contributor Author

DarthGandalf commented Oct 7, 2022

The branch does work. The difference in functionality is that the target added by find_package(ShowMySky-Qt5) is now called ShowMySky::ShowMySky. Which means that it's impossible to have a cmake project which creates 2 executables: one with ShowMySky-Qt5 and another with ShowMySky-Qt6. I don't know whether it's a big concern though.

@DarthGandalf
Copy link
Contributor Author

otherwise it'll likely not recognize the PR as merged due to the conflict resolution.

I really don't care. You can close it then by hand. Deciding whether that issue is bad enough or doesn't matter is more important than how exactly the PR is closed :)

@10110111
Copy link
Owner

10110111 commented Oct 7, 2022

Which means that it's impossible to have a cmake project which creates 2 executables: one with ShowMySky-Qt5 and another with ShowMySky-Qt6.

Well, this would be a very strange use case, which can be solved by running two separate builds. Having two Qt versions in the same build is a truly rare case.

OK, so I'm merging it.

@10110111
Copy link
Owner

10110111 commented Oct 7, 2022

Merged.

@10110111 10110111 closed this Oct 7, 2022
@DarthGandalf DarthGandalf deleted the qtver branch October 7, 2022 20:59
@DarthGandalf
Copy link
Contributor Author

Yep, that's hopefully a rare case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants