diff --git a/recipes/qt/5.x.x/conanfile.py b/recipes/qt/5.x.x/conanfile.py index 9d4a18d87ad0e..f45348ca816a3 100644 --- a/recipes/qt/5.x.x/conanfile.py +++ b/recipes/qt/5.x.x/conanfile.py @@ -1,5 +1,5 @@ from conan import ConanFile -from conan.errors import ConanInvalidConfiguration +from conan.errors import ConanException, ConanInvalidConfiguration from conan.tools.android import android_abi from conan.tools.apple import is_apple_os from conan.tools.build import build_jobs, check_min_cppstd, cross_building @@ -27,6 +27,8 @@ class QtConan(ConanFile): "qtspeech", "qtnetworkauth", "qtremoteobjects", "qtwebglplugin", "qtlottie", "qtquicktimeline", "qtquick3d", "qtknx", "qtmqtt", "qtcoap", "qtopcua"] + _module_statuses = ["essential", "addon", "deprecated", "preview"] + name = "qt" description = "Qt is a cross-platform framework for graphical user interfaces." topics = ("ui", "framework") @@ -78,6 +80,7 @@ class QtConan(ConanFile): "multiconfiguration": [True, False] } options.update({module: [True, False] for module in _submodules}) + options.update({f"{status}_modules": [True, False] for status in _module_statuses}) default_options = { "shared": False, @@ -118,8 +121,10 @@ class QtConan(ConanFile): "cross_compile": None, "sysroot": None, "config": None, - "multiconfiguration": False + "multiconfiguration": False, + "essential_modules": not os.getenv('CONAN_CENTER_BUILD_SERVICE') } + default_options.update({f"{status}_modules": False for status in _module_statuses if status != "essential"}) no_copy_source = True short_paths = True @@ -222,16 +227,6 @@ def configure(self): if not self.options.with_dbus: del self.options.with_atspi - if not self.options.qtmultimedia: - self.options.rm_safe("with_libalsa") - del self.options.with_openal - del self.options.with_gstreamer - del self.options.with_pulseaudio - - if self.settings.os in ("FreeBSD", "Linux"): - if self.options.qtwebengine: - self.options.with_fontconfig = True - if self.options.multiconfiguration: del self.settings.build_type @@ -246,6 +241,8 @@ def configure(self): modulename = section[section.find('"') + 1: section.rfind('"')] status = str(config.get(section, "status")) if status not in ("obsolete", "ignore"): + if status not in self._module_statuses: + raise ConanException(f"module {modulename} has status {status} which is not in self._module_statuses {self._module_statuses}") submodules_tree[modulename] = {"status": status, "path": str(config.get(section, "path")), "depends": []} if config.has_option(section, "depends"): @@ -267,11 +264,27 @@ def _enablemodule(mod): for module in self._submodules: if self.options.get_safe(module): _enablemodule(module) + else: + if module in submodules_tree: + for status in self._module_statuses: + if getattr(self.options, f"{status}_modules") and submodules_tree[module]['status'] == status: + _enablemodule(module) + break for module in self._submodules: if module in self.options and not self.options.get_safe(module): setattr(self.options, module, False) + if not self.options.qtmultimedia: + self.options.rm_safe("with_libalsa") + del self.options.with_openal + del self.options.with_gstreamer + del self.options.with_pulseaudio + + if self.settings.os in ("FreeBSD", "Linux"): + if self.options.qtwebengine: + self.options.with_fontconfig = True + def validate(self): if self.settings.compiler.get_safe("cppstd"): check_min_cppstd(self, "11") @@ -427,6 +440,8 @@ def package_id(self): self.info.settings.compiler.runtime_type = "Release/Debug" if self.info.settings.os == "Android": del self.info.options.android_sdk + for status in self._module_statuses: + delattr(self.info.options, f"{status}_modules") def build_requirements(self): if self._settings_build.os == "Windows" and is_msvc(self): diff --git a/recipes/qt/6.x.x/conanfile.py b/recipes/qt/6.x.x/conanfile.py index d422f6380ce6a..4a2fb7512fa85 100644 --- a/recipes/qt/6.x.x/conanfile.py +++ b/recipes/qt/6.x.x/conanfile.py @@ -12,7 +12,7 @@ from conan.tools.gnu import PkgConfigDeps from conan.tools.microsoft import msvc_runtime_flag, is_msvc from conan.tools.scm import Version -from conan.errors import ConanInvalidConfiguration +from conan.errors import ConanException, ConanInvalidConfiguration required_conan_version = ">=1.55.0" @@ -28,6 +28,8 @@ class QtConan(ConanFile): "qtspeech", "qthttpserver", "qtquick3dphysics", "qtgrpc", "qtquickeffectmaker"] _submodules += ["qtgraphs"] # new modules for qt 6.6.0 + _module_statuses = ["essential", "addon", "deprecated", "preview"] + name = "qt" description = "Qt is a cross-platform framework for graphical user interfaces." topics = ("framework", "ui") @@ -76,6 +78,7 @@ class QtConan(ConanFile): "disabled_features": [None, "ANY"], } options.update({module: [True, False] for module in _submodules}) + options.update({f"{status}_modules": [True, False] for status in _module_statuses}) # this significantly speeds up windows builds no_copy_source = True @@ -118,7 +121,9 @@ class QtConan(ConanFile): "sysroot": None, "multiconfiguration": False, "disabled_features": "", + "essential_modules": not os.getenv('CONAN_CENTER_BUILD_SERVICE') } + default_options.update({f"{status}_modules": False for status in _module_statuses if status != "essential"}) short_paths = True @@ -145,6 +150,8 @@ def _get_module_tree(self): continue status = str(config.get(section, "status")) if status not in ["obsolete", "ignore", "additionalLibrary"]: + if status not in self._module_statuses: + raise ConanException(f"module {modulename} has status {status} which is not in self._module_statuses {self._module_statuses}") assert modulename in self._submodules, f"module {modulename} not in self._submodules" self._submodules_tree[modulename] = {"status": status, "path": str(config.get(section, "path")), "depends": []} @@ -202,16 +209,6 @@ def configure(self): self.options.rm_safe("with_x11") self.options.rm_safe("with_egl") - if not self.options.get_safe("qtmultimedia"): - self.options.rm_safe("with_libalsa") - del self.options.with_openal - del self.options.with_gstreamer - del self.options.with_pulseaudio - - if self.settings.os in ("FreeBSD", "Linux"): - if self.options.get_safe("qtwebengine"): - self.options.with_fontconfig = True - if self.options.multiconfiguration: del self.settings.build_type @@ -223,9 +220,14 @@ def _enablemodule(mod): # enable all modules which are # - required by a module explicitely enabled by the consumer - for module in self._get_module_tree: - if getattr(self.options, module): - _enablemodule(module) + for module_name, module in self._get_module_tree.items(): + if getattr(self.options, module_name): + _enablemodule(module_name) + else: + for status in self._module_statuses: + if getattr(self.options, f"{status}_modules") and module['status'] == status: + _enablemodule(module_name) + break # disable all modules which are: # - not explicitely enabled by the consumer and @@ -234,6 +236,16 @@ def _enablemodule(mod): if getattr(self.options, module).value is None: setattr(self.options, module, False) + if not self.options.get_safe("qtmultimedia"): + self.options.rm_safe("with_libalsa") + del self.options.with_openal + del self.options.with_gstreamer + del self.options.with_pulseaudio + + if self.settings.os in ("FreeBSD", "Linux"): + if self.options.get_safe("qtwebengine"): + self.options.with_fontconfig = True + def validate(self): if os.getenv('CONAN_CENTER_BUILD_SERVICE') is not None: if self.info.settings.compiler == "gcc" and Version(self.info.settings.compiler.version) >= "11" or \ @@ -634,6 +646,8 @@ def package_id(self): self.info.settings.compiler.runtime_type = "Release/Debug" if self.info.settings.os == "Android": del self.info.options.android_sdk + for status in self._module_statuses: + delattr(self.info.options, f"{status}_modules") def source(self): destination = self.source_folder