Skip to content

Commit 398df56

Browse files
z3ntujpakkane
authored andcommitted
Add Qt6 module
1 parent a855bca commit 398df56

File tree

8 files changed

+74
-5
lines changed

8 files changed

+74
-5
lines changed

ci/ciimage/arch/install.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ pkgs=(
1212
itstool gtk3 java-environment=8 gtk-doc llvm clang sdl2 graphviz
1313
doxygen vulkan-validation-layers openssh mercurial gtk-sharp-2 qt5-tools
1414
libwmf valgrind cmake netcdf-fortran openmpi nasm gnustep-base gettext
15-
python-lxml hotdoc rust-bindgen
15+
python-lxml hotdoc rust-bindgen qt6-base qt6-tools
1616
# cuda
1717
)
1818

docs/markdown/snippets/qt6_module.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
## Qt6 module
2+
3+
A module for Qt6 is now available with the same functionality as the Qt5
4+
module.
5+
6+
Currently finding Qt6 is only available via `qmake` as pkg-config files aren't
7+
generated (see [QTBUG-86080](https://bugreports.qt.io/browse/QTBUG-86080)) and
8+
CMake support is not available for this module yet.

mesonbuild/dependencies/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
shaderc_factory, threads_factory,
3131
)
3232
from .platform import AppleFrameworks
33-
from .ui import GnuStepDependency, Qt4Dependency, Qt5Dependency, WxDependency, gl_factory, sdl2_factory, vulkan_factory
33+
from .ui import GnuStepDependency, Qt4Dependency, Qt5Dependency, Qt6Dependency, WxDependency, gl_factory, sdl2_factory, vulkan_factory
3434

3535

3636
# This is a dict where the keys should be strings, and the values must be one
@@ -77,6 +77,7 @@
7777
'gnustep': GnuStepDependency,
7878
'qt4': Qt4Dependency,
7979
'qt5': Qt5Dependency,
80+
'qt6': Qt6Dependency,
8081
'sdl2': sdl2_factory,
8182
'wxwidgets': WxDependency,
8283
'vulkan': vulkan_factory,

mesonbuild/dependencies/ui.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -544,6 +544,17 @@ def get_private_includes(self, mod_inc_dir, module):
544544
return _qt_get_private_includes(mod_inc_dir, module, self.version)
545545

546546

547+
class Qt6Dependency(QtBaseDependency):
548+
def __init__(self, env, kwargs):
549+
QtBaseDependency.__init__(self, 'qt6', env, kwargs)
550+
551+
def get_pkgconfig_host_bins(self, core):
552+
return core.get_pkgconfig_variable('host_bins', {})
553+
554+
def get_private_includes(self, mod_inc_dir, module):
555+
return _qt_get_private_includes(mod_inc_dir, module, self.version)
556+
557+
547558
class SDL2DependencyConfigTool(ConfigToolDependency):
548559

549560
tools = ['sdl2-config']

mesonbuild/modules/qt.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,16 @@
1717
from .. import mlog
1818
from .. import build
1919
from ..mesonlib import MesonException, extract_as_list, File, unholder, version_compare
20-
from ..dependencies import Dependency, Qt4Dependency, Qt5Dependency, NonExistingExternalProgram
20+
from ..dependencies import Dependency, Qt4Dependency, Qt5Dependency, Qt6Dependency, NonExistingExternalProgram
2121
import xml.etree.ElementTree as ET
2222
from . import ModuleReturnValue, get_include_args, ExtensionModule
2323
from ..interpreterbase import noPosargs, permittedKwargs, FeatureNew, FeatureNewKwargs
2424
from ..interpreter import extract_required_kwarg
2525

2626
_QT_DEPS_LUT = {
2727
4: Qt4Dependency,
28-
5: Qt5Dependency
28+
5: Qt5Dependency,
29+
6: Qt6Dependency,
2930
}
3031

3132

mesonbuild/modules/qt6.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Copyright 2020 The Meson development team
2+
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
from .qt import QtBaseModule
16+
17+
18+
class Qt6Module(QtBaseModule):
19+
20+
def __init__(self, interpreter):
21+
QtBaseModule.__init__(self, interpreter, qt_version=6)
22+
23+
24+
def initialize(*args, **kwargs):
25+
return Qt6Module(*args, **kwargs)

run_unittests.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6478,6 +6478,26 @@ def test_qt5dependency_qmake_detection(self):
64786478
self.assertRegex('\n'.join(mesonlog),
64796479
r'Run-time dependency qt5 \(modules: Core\) found: YES .* \((qmake|qmake-qt5)\)\n')
64806480

6481+
def test_qt6dependency_qmake_detection(self):
6482+
'''
6483+
Test that qt6 detection with qmake works. This can't be an ordinary
6484+
test case because it involves setting the environment.
6485+
'''
6486+
# Verify that qmake is for Qt5
6487+
if not shutil.which('qmake-qt6'):
6488+
if not shutil.which('qmake'):
6489+
raise unittest.SkipTest('QMake not found')
6490+
output = subprocess.getoutput('qmake --version')
6491+
if 'Qt version 6' not in output:
6492+
raise unittest.SkipTest('Qmake found, but it is not for Qt 6.')
6493+
# Disable pkg-config codepath and force searching with qmake/qmake-qt6
6494+
testdir = os.path.join(self.framework_test_dir, '4 qt')
6495+
self.init(testdir, extra_args=['-Dmethod=qmake'])
6496+
# Confirm that the dependency was found with qmake
6497+
mesonlog = self.get_meson_log()
6498+
self.assertRegex('\n'.join(mesonlog),
6499+
r'Run-time dependency qt6 \(modules: Core\) found: YES .* \((qmake|qmake-qt6)\)\n')
6500+
64816501
def glob_sofiles_without_privdir(self, g):
64826502
files = glob(g)
64836503
return [f for f in files if not f.endswith('.p')]

test cases/frameworks/4 qt/meson.build

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,13 @@ project('qt4 and 5 build test', 'cpp',
33
default_options : ['cpp_std=c++11'])
44

55
qt5_modules = ['Widgets']
6-
foreach qt : ['qt4', 'qt5']
6+
qt6_modules = ['Widgets']
7+
foreach qt : ['qt4', 'qt5', 'qt6']
78
qt_modules = ['Core', 'Gui']
89
if qt == 'qt5'
910
qt_modules += qt5_modules
11+
elif qt == 'qt6'
12+
qt_modules += qt6_modules
1013
endif
1114

1215
# Test that invalid modules are indeed not found

0 commit comments

Comments
 (0)