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

qt/6.x.x - Adding cross build support (only tested for Windows so far) #8116

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 7 additions & 8 deletions recipes/qt/6.x.x/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -616,6 +616,13 @@ def _configure_cmake(self):
self._cmake.definitions["FEATURE_pkg_config"] = "ON"
if self.settings.compiler == "gcc" and self.settings.build_type == "Debug" and not self.options.shared:
self._cmake.definitions["BUILD_WITH_PCH"]= "OFF" # disabling PCH to save disk space

if tools.cross_building(self):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ericLemanissier
I'm in no way a qt specialist.
I remember reading to cross build qt for android, you first need a native qt.
Would the following be needed instead? + setting the correct appropriate arguments.

def build_requirements(self):
    if tools.cross_building(self):
        self.build_requires(f"{self.name}/{self.version}")

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's the way qt 6 handles cross compilation yes, but I don't think conan allows it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You mean conan does not generate the required cmake modules for build requirements?
Is there missing something else?
Imho, this deserves to be added to conan.

Copy link
Contributor

@ericLemanissier ericLemanissier Nov 19, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the thing is that you usually want different options for the build qt (basically just the minimum) from the host qt.

Edit: looks like I am wrong!

qtHostPath = os.getenv("QT_HOST_PATH")
if qtHostPath:
self._cmake.definitions["QT_HOST_PATH"] = qtHostPath
else:
raise ConanInvalidConfiguration("In order to be able to cross-compile, you have to call `conan create` for the build machine (build architecture) first, and pass the path of that package to the cross-building `conan create` call using the `conan create` option : `--env QT_HOST_PATH=<path/to/the/conan/package/built/for/the/build/machine/architecture>`")

try:
self._cmake.configure(source_folder="qt6")
Expand Down Expand Up @@ -691,19 +698,11 @@ def package(self):
if module != "qtbase" and not self.options.get_safe(module):
tools.rmdir(os.path.join(self.package_folder, "licenses", module))
tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig"))
for mask in ["Find*.cmake", "*Config.cmake", "*-config.cmake"]:
tools.remove_files_by_mask(self.package_folder, mask)
Comment on lines -694 to -695
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tools.remove_files_by_mask(os.path.join(self.package_folder, "lib"), "*.la*")
tools.remove_files_by_mask(self.package_folder, "*.pdb*")
tools.remove_files_by_mask(self.package_folder, "ensure_pro_file.cmake")
os.remove(os.path.join(self.package_folder, "bin", "qt-cmake-private-install.cmake"))

for m in os.listdir(os.path.join(self.package_folder, "lib", "cmake")):
module = os.path.join(self.package_folder, "lib", "cmake", m, "%sMacros.cmake" % m)
helper_modules = glob.glob(os.path.join(self.package_folder, "lib", "cmake", m, "QtPublic*Helpers.cmake"))
if not os.path.isfile(module) and not helper_modules:
tools.rmdir(os.path.join(self.package_folder, "lib", "cmake", m))

Comment on lines -701 to -706
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above

extension = ""
if self.settings.os == "Windows":
extension = ".exe"
Expand Down