Skip to content

Commit 22df45a

Browse files
nirbheekeli-schwartz
authored andcommitted
qt: Allow specifying separate tools for qt4/5/6
Currently you can only use one of qt4, qt5, qt6 in a single project when using a machine file because the config-tool lookup for qt only looks at `qmake` in the machine files, instead of looking up the binary names directly. Allow specifying `qmake` `qmake4` `qmake5` and `qmake6`. This is necessary for gstreamer, which can build separate qt5 and qt6 plugins that are distributed as static libraries, so the user can pick which one to use.
1 parent 1f71911 commit 22df45a

3 files changed

Lines changed: 15 additions & 11 deletions

File tree

‎mesonbuild/dependencies/qt.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,11 +252,11 @@ class QmakeQtDependency(_QtBase, ConfigToolDependency, metaclass=abc.ABCMeta):
252252

253253
"""Find Qt using Qmake as a config-tool."""
254254

255-
tool_name = 'qmake'
256255
version_arg = '-v'
257256

258257
def __init__(self, name: str, env: 'Environment', kwargs: T.Dict[str, T.Any]):
259258
_QtBase.__init__(self, name, kwargs)
259+
self.tool_name = f'qmake{self.qtver}'
260260
self.tools = [f'qmake{self.qtver}', f'qmake-{self.name}', 'qmake']
261261

262262
# Add additional constraints that the Qt version is met, but preserve

‎mesonbuild/programs.py‎

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727
from . import mesonlib
2828
from . import mlog
29-
from .mesonlib import MachineChoice
29+
from .mesonlib import MachineChoice, OrderedSet
3030

3131
if T.TYPE_CHECKING:
3232
from .environment import Environment
@@ -355,15 +355,18 @@ def find_external_program(env: 'Environment', for_machine: MachineChoice, name:
355355
display_name: str, default_names: T.List[str],
356356
allow_default_for_cross: bool = True) -> T.Generator['ExternalProgram', None, None]:
357357
"""Find an external program, checking the cross file plus any default options."""
358+
potential_names = OrderedSet(default_names)
359+
potential_names.add(name)
358360
# Lookup in cross or machine file.
359-
potential_cmd = env.lookup_binary_entry(for_machine, name)
360-
if potential_cmd is not None:
361-
mlog.debug(f'{display_name} binary for {for_machine} specified from cross file, native file, '
362-
f'or env var as {potential_cmd}')
363-
yield ExternalProgram.from_entry(name, potential_cmd)
364-
# We never fallback if the user-specified option is no good, so
365-
# stop returning options.
366-
return
361+
for potential_name in potential_names:
362+
potential_cmd = env.lookup_binary_entry(for_machine, potential_name)
363+
if potential_cmd is not None:
364+
mlog.debug(f'{display_name} binary for {for_machine} specified from cross file, native file, '
365+
f'or env var as {potential_cmd}')
366+
yield ExternalProgram.from_entry(potential_name, potential_cmd)
367+
# We never fallback if the user-specified option is no good, so
368+
# stop returning options.
369+
return
367370
mlog.debug(f'{display_name} binary missing from cross or native file, or env var undefined.')
368371
# Fallback on hard-coded defaults, if a default binary is allowed for use
369372
# with cross targets, or if this is not a cross target

‎test cases/frameworks/4 qt/meson.build‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,8 @@ foreach qt : ['qt4', 'qt5', 'qt6']
152152
endif
153153

154154
# Check we can apply a version constraint
155-
dependency(qt, modules: qt_modules, version: '>=@0@'.format(qtdep.version()), method : get_option('method'))
155+
accept_versions = ['>=@0@'.format(qtdep.version()), '<@0@'.format(qtdep.version()[0].to_int() + 1)]
156+
dependency(qt, modules: qt_modules, version: accept_versions, method : get_option('method'))
156157

157158
endif
158159
endforeach

0 commit comments

Comments
 (0)