Skip to content

qt-msbuild: add new package 3.3.1 #27340

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

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

chausner
Copy link
Contributor

@chausner chausner commented May 1, 2025

Summary

Changes to recipe: qt-msbuild/3.3.1

Motivation

We already have the qt package which contains the main Qt libraries. If one does not need the moc, uic, rcc compilers, then the qt package is sufficient and can be used as-is. However, if the moc/uic/rcc compilers are needed, then one needs additional build system integration to invoke the compilers and pass the generated output to the compiler. For MSBuild, there is Qt/MSBuild which consists of a bunch of .props and .targets files which does exactly that.

Traditionally, Qt/MSBuild was only available through the Qt Visual Studio Tools extension but since a while, Qt/MSBuild is also made available standalone, e.g.: https://download.qt.io/official_releases/vsaddin/3.3.1/qt-vsaddin-msbuild-3.3.1.zip

This PR packages the standalone Qt/MSBuild as a Conan package. This allows users who already use the qt package and want to invoke the moc, uic, rcc compilers through MSBuild to use this package. The Qt VS Tools extension is then no longer needed.

Details

The proposed qt-msbuild package registers an environment variable QtMsBuild with the path to the Qt/MSBuild distribution. This is exactly what the Qt VS Tools extension does: Qt/MSBuild is shipped as part of the extension and the extension registers an environment variable that points to the directory where Qt/MSBuild is installed.

Therefore, (almost) no modifications to .vcxproj files are needed to migrate from Qt VS Tools to this package. The only requirement is that users use this package with the VirtualBuildEnv generator and activate the build environment via conanenv.bat before running devenv/MSBuild.

EDIT: There are still some build issues I would like to look into before this is ready, therefore I set this to Draft, for now.


@@ -0,0 +1,4 @@
sources:
"3.3.1":
url: "https://download.qt.io/official_releases/vsaddin/3.3.1/qt-vsaddin-msbuild-3.3.1.zip"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Alternatively, we could get Qt/MSBuild from: https://github.com/qt-labs/vstools/tree/v3.3.1/QtMSBuild/QtMsBuild. I think they are identical to the ZIP distribution, although I haven't checked. But I think it's easier to just use the standalone download links.

topics = ("qt", "msbuild")

package_type = "build-scripts"
settings = "os", "arch", "compiler", "build_type"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've noticed that other similar recipes always specify settings "os", "arch", "compiler", "build_type" even though I don't understand why.

Since the packaged contents are build scripts that are independent of any os/arch/build type, I think those settings could be removed?

class QtMSBuildConan(ConanFile):
name = "qt-msbuild"
description = "Qt/MSBuild MSBuild rules and targets from Qt VS Tools"
license = "LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

You can find this license string in any of the packaged files, e.g.: https://github.com/qt-labs/vstools/blob/v3.3.1/QtMSBuild/QtMsBuild/Qt.props#L5

from conan.tools.files import copy, get
from conan.tools.layout import basic_layout

required_conan_version = ">=1.53.0"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I haven't tested if the recipe works with Conan 1.x, I only tested with the latest 2.x version.

I've seen that other similar recipes also do

self.env_info.QtMsBuild = os.path.join(self.package_folder, "res")

which seems to be for backwards-compatibility with Conan 1.x. Should I add that or should I rather specify

required_conan_version = ">=2.0"

?

@chausner chausner marked this pull request as draft May 4, 2025 20:02
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.

1 participant