conan-io / conan-center-index

Recipes for the ConanCenter repository
https://conan.io/center
MIT License
967 stars 1.78k forks source link

[bug] qt/6.3.0, qt/5.15.3: Structures of some folders are not unified. #11261

Open hwhsu1231 opened 2 years ago

hwhsu1231 commented 2 years ago

Problem Descriptions

Take plugins folder for example.

I noticed that

However,

Obviously, the locations of plugins folder are different from Qt5 and Qt6 installed from ConanCenter. Not to mention that they are all different from the location of it installed from Official Installer.

I think it had better followed the structure of Qt Official. At least, Qt5 and Qt6 should use the same structure.

Screenshots

image image image image

ericLemanissier commented 2 years ago

Well, conan-center has some rules about package folder layout: https://github.com/conan-io/conan-center-index/blob/10aad636633cf0a2fa4ae9c3c6b1ecf38d270e9d/docs/error_knowledge_base.md#kb-h013-default-package-layout. Making an exception is possible, but we need a strong reason, for exemples if it makes the package not usable.

hwhsu1231 commented 2 years ago

@ericLemanissier Here is a problem I encountered.

On Windows platform, it is required to copy *.dll files to the output directory when using "x:shared": true option. Therefore, Conan provides us to use imports() method in conanfile.py or imports section in conanfile.txt. The following is an example of conanfile.py I currently use:

Click to expand ```python from conans import ConanFile, CMake class ConsumerConan(ConanFile): settings = "os", "compiler", "build_type", "arch" generators = "CMakeDeps", "VirtualRunEnv" requires = [ "qt/6.3.0" ] default_options = { "qt:shared": True, "qt:qttranslations" : True, "qt:qt5compat": True } def imports(self): if self.settings.build_type == "Debug": self.copy("*.dll", dst="../Debug/bin", src="bin") self.copy("*.dylib*", dst="../Deubg/bin", src="lib") if self.settings.build_type == "Release": self.copy("*.dll", dst="../Release/bin", src="bin") self.copy("*.dylib*", dst="../Release/bin", src="lib") ```

However, it is NOT enough to just copy *.dll files for Qt. According to my situations, I also need to copy platforms and styles folder into the output directory. However, the locations of these two folders are NOT the same in Qt5 and Qt6 installed from ConanCenter. Which means:

If I want to make my project compatible with both Qt5 and Qt6. That would be a problem.

Screenshots

image

ericLemanissier commented 2 years ago

Can you try to use windeployqt instead of doing the copy manually ? Edit : I also agree that the folder layout has to be unified. Don't hesitate to make a PR on qt5 putting archdatadir in bin instead of res

technic commented 2 years ago

There is a bigger issue with this. Those folders are not only used to place files on the disk, but they are also put inside Qt6/Qt5Core.dll here. Then QCoreApplication::libraryPaths() has a special logic to locate Qt plugins (platform, styles, etc) which are loaded dynamically during application startup. This logic can be found here and in QLibraryInfo::path. You can see that Qt code is looking for Qt plugins in the path given by qt_configure_strs relative to the location of the Qt6Core.dll, and it is also looking directly in the directory where Qt6Core.dll is located. Same thing with the Qt5. For example in the screenshot above Qt from conan will search for platform plugins in folders:

Qt form official installer will instead search in folders:

This is an important thing to consider when deploying a Qt application, and I think introducing such difference inside a conan package is a bad idea.