Skip to content

Commit

Permalink
(conan-io#20587) qt6: do not define default_options for modules
Browse files Browse the repository at this point in the history
closes conan-io#20565
fixes conan-io#20383

also, be a little more strict with options usage
  • Loading branch information
ericLemanissier authored Oct 27, 2023
1 parent 79c5a17 commit 093e199
Showing 1 changed file with 19 additions and 9 deletions.
28 changes: 19 additions & 9 deletions recipes/qt/6.x.x/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ class QtConan(ConanFile):
"multiconfiguration": False,
"disabled_features": "",
}
default_options.update({module: False for module in _submodules})

short_paths = True

Expand All @@ -140,15 +139,16 @@ def _get_module_tree(self):
assert section.startswith("submodule ")
assert section.count('"') == 2
modulename = section[section.find('"') + 1: section.rfind('"')]
if modulename in ["qtbase", "qtqa", "qtrepotools"]:
continue
status = str(config.get(section, "status"))
if status not in ["obsolete", "ignore", "additionalLibrary"]:
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": []}
if config.has_option(section, "depends"):
self._submodules_tree[modulename]["depends"] = [str(i) for i in config.get(section, "depends").split()]

for m in self._submodules_tree:
assert m in ["qtbase", "qtqa", "qtrepotools"] or m in self._submodules, f"module {m} not in self._submodules"

return self._submodules_tree

Expand Down Expand Up @@ -214,12 +214,21 @@ def configure(self):
def _enablemodule(mod):
if mod != "qtbase":
setattr(self.options, mod, True)
for req in self._get_module_tree[mod]["depends"]:
_enablemodule(req)
for req in self._get_module_tree[mod]["depends"]:
_enablemodule(req)

# enable all modules which are
# - required by a module explicitely enabled by the consumer
for module in self._get_module_tree:
if self.options.get_safe(module):
if getattr(self.options, module):
_enablemodule(module)

# disable all modules which are:
# - not explicitely enabled by the consumer and
# - not required by a module explicitely enabled by the consumer
for module in self._get_module_tree:
if getattr(self.options, module).value is None:
setattr(self.options, module, False)

def validate(self):
if os.getenv('NOT_ON_C3I', '0') == '0':
Expand Down Expand Up @@ -461,8 +470,9 @@ def generate(self):
tc.variables["FEATURE_optimize_size"] = ("ON" if self.settings.build_type == "MinSizeRel" else "OFF")

for module in self._get_module_tree:
if module != 'qtbase':
tc.variables[f"BUILD_{module}"] = ("ON" if self.options.get_safe(module) else "OFF")
tc.variables[f"BUILD_{module}"] = ("ON" if getattr(self.options, module) else "OFF")
tc.variables["BUILD_qtqa"] = "OFF"
tc.variables["BUILD_qtrepotools"] = "OFF"

tc.variables["FEATURE_system_zlib"] = "ON"

Expand Down Expand Up @@ -765,7 +775,7 @@ def package(self):
copy(self, "*LICENSE*", self.source_folder, os.path.join(self.package_folder, "licenses"),
excludes="qtbase/examples/*")
for module in self._get_module_tree:
if module != "qtbase" and not self.options.get_safe(module):
if not getattr(self.options, module):
rmdir(self, os.path.join(self.package_folder, "licenses", module))
rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig"))
for mask in ["Find*.cmake", "*Config.cmake", "*-config.cmake"]:
Expand Down

0 comments on commit 093e199

Please sign in to comment.